Support » Plugins and Hacks » [Resolved] Meta Boxes on specific theme template page

[Resolved] Meta Boxes on specific theme template page

  • Is there any way to add a few meta boxes to say just the homepage which in my case has a custom theme page template of home-page.php

    I realize I could do this as a theme option and simply create a new option section called “Home page” and create the fields there, but I think it makes more sense from a usability perspective to place the meta boxes for the callout boxes on the homepage actually on the Home page WP edit screen.


Viewing 4 replies - 1 through 4 (of 4 total)
  • Yes, it’s easy to do that.
    – Create a template for home page (ex: home-page.php).
    – Create an OptionTree Custom Metabox (see document) for Home page. Before the line of PHP code that register OptionTree Custom Metabox you add some line of code to check if editing page has template name is home-page.php then register metabox otherwise bypass register code. In WP page edit screen choose your homepage template in template select box and save page. Your metabox for home page will show.

    I did this and worked very well for me. The only problem is that you have to save the post an then the meta box appear.

    $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
    $template_file = get_post_meta($post_id, '_wp_page_template', TRUE);
    if ($template_file == 'template-quienessomos.php') {
        ot_register_meta_box( $quienessomos_meta_box );

    If you want to show specific metabox for new post that not save yet, you must regirster all metaboxes in PHP and use JS to show metabox base on what tempate is selected.

    Plugin Author Derek Herman


    @franciscoamk and @htvu are correct. Currently the code base does not support this feature and you’ll need to do one of the two option listed above. Hopefully in the future I’ll figure out an elegant way to do this, but I’ve not come up with one yet.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Meta Boxes on specific theme template page’ is closed to new replies.