0

I want to put the custom metabox I have only on the home page but I am not sure how to go about doing this. I am using the following to add the custom meta box to all the pages. How would I select just the home page, or home.php template or that ID. I am really just not sure of the syntax.

<?php
$custom_mb = new WPAlchemy_MetaBox(array
(
    'id' => '_custom_meta',
    'title' => 'Add images to home page slider',
    'template' => get_stylesheet_directory() . '/metaboxes/custom-meta.php',
    'types' => array('page'),
));
?>
1
new WPAlchemy_MetaBox(array
(
    'id' => '_custom_meta',
    'title' => 'My Custom Meta',
    'template' => STYLESHEETPATH . '/custom/meta.php',
    'exclude_template' => 'product.php'
));

the 'exclude_template' would work for excluding the one's you didn't want.

new WPAlchemy_MetaBox(array
(
    'id' => '_custom_meta',
    'title' => 'My Custom Meta',
    'template' => STYLESHEETPATH . '/custom/meta.php',
    'include_template' => array('product.php','press.php') // use an array for multiple items
    // 'include_template' => 'product.php,press.php' // comma separated lists work too
));

including works the same.

Here's how you'd include only by post ID (Which if you're designing this for a client I wouldn't do they tend to break the Post ID's by midweek).

'include_post_id' => 97

Here's a link: http://www.farinspace.com/wpalchemy-metabox/#filter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.