Custom Fields
Re-Envisioned
Support Meta Box Show Hide (Javascript) Only show meta box on page with template named this-template.php Reply To: Only show meta box on page with template named this-template.php

#11265

Anh Tran
Keymaster

Hi Philip,

Please add show parameter to the meta box settings as follows:

function testmeta( $meta_boxes ) {
    $prefix = 'swed-';

    $meta_boxes[] = array(
        'id' => 'vendoroptions',
        'title' => esc_html__( 'Vendors', 'metabox-online-generator' ),
        'post_types' => array( 'page' ),
        'context' => 'after_title',
        'priority' => 'high',
        'autosave' => false,
        'show' => array(
            'template' => array( 'this-template.php' ),
        ),
        'fields' => array(),
   );
   return $meta_boxes;
} );

For more details, please see the documentation.