This repository has been archived by the owner on Dec 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 419
Display Options
billerickson edited this page Nov 1, 2011
·
6 revisions
Metaboxes should be context-specific, and only show up when relevant. There's two tools you can use to limit their display:
- pages - limits the post types it applies to
- show_on - can limit to specific page/post IDs, page templates, or any other show_on filter you define
Both of these are used when you define your metabox.
For every metabox you create, you should specify the to which it applies. They'll be listed as an array. Here's an example that only applies to pages:
$meta_boxes[] = array(
'id' => 'test_metabox',
'title' => 'Test Metabox',
'pages' => array('page'), // post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => array( ...
Here's an example that displays on posts and events:
$meta_boxes[] = array(
'id' => 'test_metabox',
'title' => 'Test Metabox',
'pages' => array('post', 'event'), // post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => array(