Skip to content

Instantly share code, notes, and snippets.

@erikccoder
Created May 10, 2013 04:57
Show Gist options
  • Save erikccoder/5552470 to your computer and use it in GitHub Desktop.
Save erikccoder/5552470 to your computer and use it in GitHub Desktop.
wordpress add meta box in edit post page.
/**
add custome meta box.
* Calls the class on the post edit screen
*/
function call_someClass()
{
return new someClass();
}
if ( is_admin() )
add_action( 'load-post.php', 'call_someClass' );
/**
* The Class
*/
class someClass
{
const LANG = 'some_textdomain';
public function __construct()
{
add_action( 'add_meta_boxes', array( &$this, 'add_some_meta_box' ) );
}
/**
* Adds the meta box container
*/
public function add_some_meta_box()
{
add_meta_box(
'some_meta_box_name'
,__( 'Some Meta Box Headline', self::LANG )
,array( &$this, 'render_meta_box_content' )
,'page'
,'advanced'
,'high'
);
}
/**
* Render Meta Box content
*/
public function render_meta_box_content()
{
echo '<h1>TEST OUTPUT - this gets rendered inside the meta box.</h1>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment