venerdì 18 marzo 2016

Metabox in base al template

su functions.php


if (is_admin()) {

$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
$template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
 
// controlla se è un template specifico

  if ($template_file == 'page-template.php') {


// codice che genera i meta box (in questo caso ho usato le classi wpalchemy)
  $custom_select_mb = new WPAlchemy_MetaBox(array
(
'id' => '_pagina_cat',
'title' => 'Select Inputs',
'template' => get_stylesheet_directory() . '/metaboxes/select-meta.php',
));  
  }
 
  }

Nessun commento: