Skip to content

Instantly share code, notes, and snippets.

@ksuzushima
Created May 8, 2018 07:55
Show Gist options
  • Save ksuzushima/5aee24be50ecda154f017e5dd49266a9 to your computer and use it in GitHub Desktop.
Save ksuzushima/5aee24be50ecda154f017e5dd49266a9 to your computer and use it in GitHub Desktop.
Basic usage for add_meta_box #wordpress #add_meta_box
<?php
/**
* Basic usage add_meta_box
* @link https://developer.wordpress.org/reference/functions/add_meta_box/
*/
add_action( 'add_meta_boxes', 'add_custom_meta_box' );
/**
* Add custom meta box
*/
public function add_custom_meta_box() {
add_meta_box(
'meta_box_id', // id
'Meta box title', // title
'show_custom_meta_box', // callback
'post', // post_type
'side', // context
'high' // priority
);
}
/**
* Custom meta box collback function
*/
public function show_custom_meta_box() {
echo 'Here, your meta box content.';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment