WordPress.org

Ready to get started?Download WordPress

Forums

Adding custom meta boxes to custom template (1 post)

  1. rikardo85
    Member
    Posted 1 year ago #

    Hello,

    I am looking to display my custom meta boxes on a custom page tmeplate.

    I have created the CMB without any problems along with the page template.

    I have found some answers on various forums but these do not seem to work for me.

    I have found the following:

    function featureBoxes()
    {
    
    $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
    $template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
    if ($template_file == 'boxes.php')
     {
        add_meta_box
           (
            'Feature box',
            'Feature box',
    	'featureBox',
            'page',
            'normal',
            'high'
           );
     }
    }

    Any help much appreciated

Topic Closed

This topic has been closed to new replies.

About this Topic