Support Forum
I must be going mad. I just can't figure out why it won't work. I've copied it from another site that's working perfectly and just changed the names and I'm not getting the metaboxes on the page in question. My code is below:
// Metaboxes (requires meta box plugin)
add_filter( 'rwmb_meta_boxes', 'chilli_register_meta_boxes' );
function chilli_register_meta_boxes( $meta_boxes ) {
$prefix = 'chilli_';
/*
Homepage columns
*/
$meta_boxes[] = array(
'id' => 'column1',
'title' => 'Column 1',
'pages' => array( 'post', 'page' ),
'context' => 'normal',
'priority' => 'high',
'include' => array(
'template' => array( 'page-home.php' ),
),
'fields' => array(
array(
'name' => 'Image',
'desc' => 'Column 1 image',
'id' => $prefix . 'image1',
'type' => 'image_advanced',
),
array(
'name' => 'Column 1 text',
'desc' => 'Text for column 1',
'id' => $prefix . 'column1',
'type' => 'wysiwyg',
),
)
);
$meta_boxes[] = array(
'id' => 'column2',
'title' => 'Column 2',
'pages' => array( 'post', 'page' ),
'context' => 'normal',
'priority' => 'high',
'include' => array(
'template' => array( 'page-home.php' ),
),
'fields' => array(
array(
'name' => 'Image',
'desc' => 'Column 2 image',
'id' => $prefix . 'image2',
'type' => 'image_advanced',
),
array(
'name' => 'Column 2 text',
'desc' => 'Text for column 2',
'id' => $prefix . 'column2',
'type' => 'wysiwyg',
),
)
);
$meta_boxes[] = array(
'id' => 'column3',
'title' => 'Column 3',
'pages' => array( 'post', 'page' ),
'context' => 'normal',
'priority' => 'high',
'include' => array(
'template' => array( 'page-home.php' ),
),
'fields' => array(
array(
'name' => 'Image',
'desc' => 'Column 3 image',
'id' => $prefix . 'image3',
'type' => 'image_advanced',
),
array(
'name' => 'Column 3 text',
'desc' => 'Text for column 3',
'id' => $prefix . 'column3',
'type' => 'wysiwyg',
),
)
);
}
Any ideas why I'm not getting any metaboxes?
You missed the return $meta_boxes
statement at the end of the function. Please try adding it.
Ah, of course, that's the bit I didn't copy and paste! Thanks.