Wordpress的特定页面定制metabox
答
为此我使用优秀的Core Metabox Library。它很容易实现,并且可以做任何事情,据我所知。
这是从相关GitHub wiki页:
$meta_boxes[] = array(
'id' => 'contact-information',
'title' => 'Contact Information',
'pages' => array('page'), // post type
'show_on' => array('key' => 'id', 'value' => array(50, 24)),
'context' => 'normal', // 'normal', 'advanced', or 'side'
'priority' => 'high', // 'high', 'core', 'default' or 'low'
'show_names' => true, // Show field names on the left
'fields' => array(
类型的show_on过滤器(key)的“ID”和该过滤器的价值是你的ID数组。如果你只想在关于页面上使用它,你可以使用'value'=> 50,而不是把它放在数组中。
如果你不想使用这个库,你会发现由内而外在看看更多的线索:在图书馆的init.php线100,但它确实是这样的:
if(conditions_met())
add_meta_box(params) ;
(认真地说,虽然 - 只是使用它所有 - 它上传,tinymce,分类,作品!)
希望帮助! Tim
我找到了使用$ _GET的方法...买我不知道这是不是最好的选择! – Uffo 2012-03-18 17:00:59