Skip to content

Instantly share code, notes, and snippets.

@designbuildtest
Created February 17, 2015 02:10
Show Gist options
  • Save designbuildtest/be3cbbaeeb66e98a97cb to your computer and use it in GitHub Desktop.
Save designbuildtest/be3cbbaeeb66e98a97cb to your computer and use it in GitHub Desktop.
Exclude a Metabox when Page is nominated as page_on_front
function myplugin_include_in_menu_meta_box() {
// Assign the ID of the page we're attempting to edit to a variable.
if ( isset( $_GET['post'] ) ) { $post_id = $_GET['post']; }
elseif ( isset( $_POST['post_ID'] ) ) { $post_id = $_POST['post_ID']; }
// Display metabox if we're creating a new page or editing a page other than the Homepage.
$front_page = get_option('page_on_front');
if ( ! isset($post_id) || ($post_id != $front_page) ) {
add_meta_box( 'myplugin_include_in_menu', __( 'Include in Navigation' ), 'myplugin_include_in_menu_meta_box_callback', 'page', 'side', 'default' );
}
}
add_action( 'add_meta_boxes', 'myplugin_include_in_menu_meta_box' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment