Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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'),
));
?>
share|improve this question

1 Answer 1

up vote 1 down vote accepted
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

share|improve this answer
    
Thanks! A lot Man –  Anders Kitson Mar 14 '12 at 17:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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