不确定您是否真的需要使用自定义管理框,除非您需要自定义标签等。。。
<?php
function my_connection_types() {
// Make sure the Posts 2 Posts plugin is active.
if ( !function_exists( \'p2p_register_connection_type\' ) )
return;
p2p_register_connection_type( array(
\'name\' => \'cpt1_to_cpt2\',
\'from\' => \'cpt1\',
\'to\' => \'cpt2\',
\'admin_box\' => \'from\',
\'fields\' => array(
\'field_name\' => \'field_title\',
\'field_name2\' => \'field_title2\'
)
) );
}
add_action( \'wp_loaded\', \'my_connection_types\' );
?>
如果需要添加自定义标签,可以扩展注册数组以包括:
\'from_labels\' => array(
\'singular_name\' => __( \'Person\', \'my-textdomain\' ),
\'search_items\' => __( \'Search people\', \'my-textdomain\' ),
\'not_found\' => __( \'No people found.\', \'my-textdomain\' ),
\'create\' => __( \'Create Connections\', \'my-textdomain\' ),
),
然后,要根据连接更新重力表单中的表单字段,可以使用gform\\u pre\\u渲染过滤器填充字段;类似于:
http://www.gravityhelp.com/documentation/page/Dynamically_Populating_Drop_Down_Fieldshttp://www.gravityhelp.com/documentation/page/Gform_pre_render
时间很短,但如果有机会,我会更新一个更具体的Posts2Posts示例。我相信,如果你深入了解一下他的admin box类,你将能够将其与上面的过滤器结合起来,得到你想要的结果。