Help with custom show_on
-
Hi there,
I’m really loving CMB2 and it will most likely become a huge part of my WordPress workflow. However, I’m having trouble understanding how the custom show_on filters work.I have CMB2 inside a plugin like this:
plugin_folder/
– cmb2/
– functionality.phpSo, let’s say I have some metaboxes in my functionality.php file, formatted like so:
$meta_boxes['slide_fields'] = array( 'id' => 'slide_fields', 'title' => __( 'In Slider?'), 'object_types' => array('slides'), 'context' => 'side', 'priority' => 'high', 'show_names' => false, 'fields' => array( array( 'name' => __( 'Featured Slide', 'cmb2' ), 'desc' => __( 'Show in slider? Only most recent 2 features will be displayed.', 'cmb2' ), 'id' => $prefix . 'slider_checkbox', 'type' => 'checkbox', ) ), );
…and then I want them to only show on a page with slug of ‘home’. So, I grab this filter. But how do use this filter?
Would I write something like this?
be_metabox_show_on_slug( true, $meta_boxes[slide_fields']);
Should this be inside of my $meta_boxes array somehow?
I’ve spent almost an hour trying to figure this out and apparently my brain just isn’t making the connection. Any help would be much appreciated.
- The topic ‘Help with custom show_on’ is closed to new replies.