I am having trouble getting the parent functionality to work with the include/exclude plugin.
I am working with normal "pages" (not posts). I assume since only pages have parent functionality out of the box with WP that this should be working fine.
The idea is to have the meta boxes included for all child pages of said parent.
Is this tested on the latest version of WordPress with the latest version of Meta Box? Here is my code below, please let me know if I am doing it wrong.
// CUSTOM METABOXES VIA META-BOX PLUGIN
$prefix = 'trf_';
global $meta_boxes;
$meta_boxes = array();
// Events
$meta_boxes[] = array(
'id' => 'events',
'title' => __( 'Event Details', 'rwmb' ),
'pages' => array( 'page' ),
// Register this meta box for posts matched below conditions
'include' => array(
'relation' => 'OR',
'parent' => array( 4899 ),
),
'fields' => array(
array(
'name' => __( 'Event Date', 'rwmb' ),
'id' => "{$prefix}event-date",
'type' => 'text',
),
array(
'name' => __( 'Event Time', 'rwmb' ),
'id' => "{$prefix}event-time",
'type' => 'text',
),
array(
'name' => __( 'Event Location', 'rwmb' ),
'id' => "{$prefix}event-location",
'type' => 'text',
),
)
);
/********************* META BOX REGISTERING ***********************/
function trf_register_meta_boxes()
{
// Make sure there's no errors when the plugin is deactivated or during upgrade
if ( !class_exists( 'RW_Meta_Box' ) )
return;
global $meta_boxes;
foreach ( $meta_boxes as $meta_box )
{
new RW_Meta_Box( $meta_box );
}
}
add_action( 'admin_init', 'trf_register_meta_boxes' );