metabox(sample)

Display a meta box container located below posts and/or pages.

How to Create

Can be created from TitanFramework Instance:

$titan = TitanFramework::getInstance( 'my-theme' );
$metaBox = $titan->createMetaBox( array(
'name' => 'My Meta Box',
) );
// Create options in My Meta Box
$metaBox->createOption( ... );

[zilla_alert]This will create a meta box named ‘My Meta Box’ on the bottom of screen when editing pages.[/zilla_alert]

Settings / Parameters

Parameter Type Description
name string The name of the meta box. This is displayed on the top of the meta box.
desc string (Optional) The description to be displayed just below the title of the meta box.
post_type mixed (Optional) The post type to display this meta box in. This can either be a string name of a post type, or an array of post types. Can also be a custom post type. Defaults to page
context string (Optional) The part of the page where the meta box will be shown. Values can be normal, advanced, or side. Note that meta boxes in Titan are currently only optimized to be displayed in normal context. Defaults to normal
priority string (Optional) The priority within the context where the boxes should show. Values can be high, core, default or low. Defaults to high
hide_custom_fields boolean (Optional) If false, the custom fields meta box will be shown. Defaults to true

Examples

Creating a meta box for pages:

$titan = TitanFramework::getInstance( 'my-theme' );
$pageMetaBox = $titan->createMetaBox( array(
'name' => 'Additional Page Options',
) );

Creating a meta box for posts:

$titan = TitanFramework::getInstance( 'my-theme' );
$postMetaBox = $titan->createMetaBox( array(
'name' => 'Additional Post Options',
'post_type' => 'post',
) );

Creating the same meta box for multiple post types:

$titan = TitanFramework::getInstance( 'my-theme' );
$postMetaBox = $titan->createMetaBox( array(
'name' => 'Additional Post Options',
'post_type' => array( 'page', 'post', 'my_other_post_type' ),
) );