为什么不。。。
$my_post_types = array(
\'post\',
\'page\',
\'topic\',
\'case\',
\'note\',
\'question\',
\'therapy_guideline\'
);
p2p_register_connection_type( array(
\'name\' => \'my_post_relationships\',
\'from\' => $my_post_types,
\'to\' => $my_post_types,
\'sortable\' => \'any\',
\'reciprocal\' => false,
\'cardinality\' => \'many-to-many\',
\'title\' => array(
\'from\' => \'Children\',
\'to\' => \'Parent\',
),
\'admin_column\' => \'any\',
)
);
或者类似的东西?
编辑:
使用前面提到的数组,可以在不需要所有键入的情况下获取多个框。
foreach($my_post_types as $post_type){
// use line below if you don\'t ever need to relate posts to posts, pages to pages, etc.
$temp_array = array_diff($my_post_types, array($post_type));
p2p_register_connection_type( array(
\'name\' => \'my_\'.$post_type.\'_connections\',
\'from\' => $temp_array, // use $my_post_types if you didn\'t define $temp_array
\'to\' => $post_type,
\'sortable\' => \'any\',
\'reciprocal\' => false,
\'cardinality\' => \'many-to-many\',
\'admin_column\' => \'any\',
)
)
}
temp数组使每个post类型都与其他post类型相关,而不是与自身相关。不确定这是不是你想要的东西,很容易移除。