Show field in backend only on certain posts
-
Hello,
I can’t really find this option, perhaps it does not exist or I may be doing it wrong, but I am hoping someone can help me out.
I want a custom field only to show on a a child page. So I have this in my custom plugin code:
if(function_exists("register_field_group")) { register_field_group(array ( 'id' => 'acf_webinar', 'title' => 'Webinar', 'fields' => array ( array ( 'key' => 'field_525fffb950527', 'label' => 'Webinar code', 'name' => 'webinar_code', 'type' => 'text', 'default_value' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'formatting' => 'html', 'maxlength' => '', ), ), 'location' => array ( array ( array ( 'param' => 'post_type', 'operator' => '==', 'value' => 'course', 'order_no' => 0, 'group_no' => 0, ), array ( 'param' => 'page_type', 'operator' => '==', 'value' => 'child', 'order_no' => 1, 'group_no' => 0, ), array ( 'param' => 'post_parent', 'operator' => '==', 'value' => $this->options['webinar_parent'], 'order_no' => 2, 'group_no' => 0, ), ), ), 'options' => array ( 'position' => 'side', 'layout' => 'default', 'hide_on_screen' => array ( ), ), 'menu_order' => 0, )); }
But some how the post_parent option doesn’t seem to be working. The variable $this->options[‘webinar_parent’] contains the right value, but even if I replace it with a hardcoded post ID it’s still not working.
I can’t really find this in the documentation, but I’m hoping some one over here can help me out. I want this field only to show if the post is a child of the webinar parent.
Regards,
Mark
- The topic ‘Show field in backend only on certain posts’ is closed to new replies.