我正在尝试使用重力表单,允许用户向我的CPT提交帖子,并选择可选的连接帖子类型。
我有两个CPT,CPT1和CPT2。
当他们查看我在CPT1下创建帖子的表单时,我希望他们能够选择CPT2下的关联帖子。
我一直遵循特拉维斯·史密斯的指示creating a custom field, 进展相当顺利。
然而,我正在努力遵循Posts 2 Posts documentation 关于添加自定义管理框。
我不知道从哪里开始,如何实现我想要实现的目标。
有什么建议吗?
我正在尝试使用重力表单,允许用户向我的CPT提交帖子,并选择可选的连接帖子类型。
我有两个CPT,CPT1和CPT2。
当他们查看我在CPT1下创建帖子的表单时,我希望他们能够选择CPT2下的关联帖子。
我一直遵循特拉维斯·史密斯的指示creating a custom field, 进展相当顺利。
然而,我正在努力遵循Posts 2 Posts documentation 关于添加自定义管理框。
我不知道从哪里开始,如何实现我想要实现的目标。
有什么建议吗?
不确定您是否真的需要使用自定义管理框,除非您需要自定义标签等。。。
<?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类,你将能够将其与上面的过滤器结合起来,得到你想要的结果。
我正在尝试使用重力表单,允许用户向我的CPT提交帖子,并选择可选的连接帖子类型。
我有两个CPT,CPT1和CPT2。
当他们查看我在CPT1下创建帖子的表单时,我希望他们能够选择CPT2下的关联帖子。
我一直遵循特拉维斯·史密斯的指示creating a custom field, 进展相当顺利。
然而,我正在努力遵循Posts 2 Posts documentation 关于添加自定义管理框。
我不知道从哪里开始,如何实现我想要实现的目标。
有什么建议吗?
不确定您是否真的需要使用自定义管理框,除非您需要自定义标签等。。。
<?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类,你将能够将其与上面的过滤器结合起来,得到你想要的结果。
一切都好吗<我需要wp-list-table 也要显示custom-fields 在每个custom-post 我有,但我不知道如何做到这一点,在这幅图中,它显示了带有字段的表格:Title, Author and Publication Date: 我想要的是能够选择custom-fields 将出现,例如以下示例Title, Carta, Naipe, Author, and Date of Publication: