0

Using the Meta Boxes plugin, is there a way to restrict the meta box to only show on a page with a specific taxonomy?

$meta_boxes[] = array(
    'id' => 'sponsor_list',                 
    'title' => 'Sponsors',              
    'pages' => array( 'page' ),             
    'context' => 'normal',                  
    'priority' => 'high',                   

    'fields' => array( 
        array(
            'name' => 'Sponsor Logos',
            'desc' => 'Upload sponsor logos here',
            'id' => $prefix . 'sponsor_logos',
            'type' => 'image' 
        )
    )
);

Which works, but shows up on all pages. I would like the meta box to only show up on pages that have a specific taxonomy. Is this possible, or does it mean creating a new CPT with a post_type of page, then attaching the meta box to it?

UPDATE

Here is the taxonomy

// Location taxononomy
function create_artists_sites() 
{
  $labels = array(
    'name' => _x( 'Festival Sites', 'taxonomy general name' ),
    'singular_name' => _x( 'Festival Site', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Festival Sites' ),
    'all_items' => __( 'All Festival Sites' ),
    'parent_item' => __( 'Parent Festival Sites' ),
    'parent_item_colon' => __( 'Parent Festival Sites:' ),
    'edit_item' => __( 'Edit Festival Site' ), 
    'update_item' => __( 'Update Festival Site' ),
    'add_new_item' => __( 'Add New Festival Site' ),
    'new_item_name' => __( 'New Festival Site Name' ),
    'menu_name' => __( 'Festival Sites' ),
  );    

  register_taxonomy('artists_sites', array('page'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'artists-sites' ),
  ));
}

The meta box has been added to all pages

$meta_boxes[] = array(
...
'pages' => array( 'page' ),

I need a condition for the meta that states

 if(any festival taxonomy is checked) { 
   show meta box 
} else {
   don't show meta
}

The ultimate goal being I don't have meta boxes not relative to a specific page in the CMS.

Thinking on this further, it could be a condition of the page template as well.

Let's say I have a page with a template: landing

Then the condition could be:

if(page has landing template) {
   show meta box
} else {
   don't show meta
}
Carey Estes
  • 1,534
  • 2
  • 31
  • 59
  • What specific taxonomy is this? Do you need a single term or the whole taxonomy? Did you attached a custom taxonomy to the Page post type? What's the full code for this meta box insertion? – brasofilo Mar 21 '13 at 21:42
  • I have added the full code for the taxonomy. – Carey Estes Mar 28 '13 at 22:47

0 Answers0