Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

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:

Both of these are used when you define your metabox.

Limit to specific post types

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(