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.

For my WordPress theme I have a custom portfolio post type and a portfolio page template to display them. What I want to do is add a meta box to the edit page area, but only when the page has the portfolio template.

Thanks.

share|improve this question
add comment

1 Answer

function my_portfolio_meta_box_cb($post) {
     $template = get_post_meta($post->ID, '_wp_page_template', true);
     if ($template == 'portfolio.php') {
         add_meta_box(........);
     }
}

Hook this via the register_meta_box_cb arg when registering the post type or in your manually via add_meta_boxes-portfolio hook.

share|improve this answer
    
sorry for my english, how can we put this in a select option onchenge it meen that when qe choise the template the add_meta_box apear just in that moment. thanks h. –  user5010 Apr 30 '11 at 17:47
add comment

Your Answer

 
discard

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