我有一个名为"Designer"的自定义帖子类型每个帖子将使用不同的唯一高级自定义字段,因为每个帖子都有唯一的模板.通过以下代码,我可以为Designer帖子类型中的每个帖子提供规则并保存但自定义字段没有显示在后端的帖子编辑页面上.通常这个代码应该ork但不知道代码发生了什么
请帮忙.
add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types( $choices )
{
$choices['Custom Post types']['cpt_parent'] = 'Custom post type parent';
return $choices;
}
add_filter('acf/location/rule_values/cpt_parent', 'acf_location_rules_values_cpt_parent');
function acf_location_rules_values_cpt_parent( $choices )
{
$args = array(
'hierarchical' => true,
'_builtin' => false
);
$posttypes = get_post_types( $args );
if( $posttypes )
{
foreach( $posttypes as $posttype ):
if( $posttype != 'acf' ):
$args = array(
'post_type' => 'designer',
'posts_per_page' => -1,
'post_status' => 'publish'
);
$customposts = get_posts( $args );
if ( $customposts ) {
foreach( …Run Code Online (Sandbox Code Playgroud)