Remove “show sharing buttons” metabox Jetpack from custom post type

you can try this if (is_admin()){ function my_remove_meta_boxes() { global $typenow; if( ‘YOUR_CUSTOM_POST_TYPE’ == $typenow ) { remove_meta_box(‘sharing_meta’, ‘YOUR_CUSTOM_POST_TYPE’, ‘high’); } } add_action( ‘admin_menu’, ‘my_remove_meta_boxes’ ); } Which removes the metabox registered by the jetpack plugin. Just make sure to change YOUR_CUSTOM_POST_TYPE with the actual name of your custom post type.

Moving meta boxes in admin

You can remove the default post tags metabox and then add it again in the desired location, ex: add_action( ‘add_meta_boxes’, ‘move_tags_metabox_location’, 0 ); function move_tags_metabox_location(){ global $wp_meta_boxes; unset( $wp_meta_boxes[‘post’][‘side’][‘core’][‘tagsdiv-post_tag’] ); add_meta_box( ‘tagsdiv-post_tag’, ‘Tags’, ‘post_tags_meta_box’, ‘post’, ‘normal’, ‘core’, array( ‘taxonomy’ => ‘post_tag’ )); }

Why are my queries interfering with the global post variable?

$the_query->the_post(); is populating the global $post with each post in that loop. On front-end queries, you’d normally call wp_reset_postdata() after running a secondary query loop, but that doesn’t work on the admin side. Use get_posts instead of WP_Query, and iterate over the results with a foreach loop- $my_posts = get_posts( $args ); if( !empty( $my_posts … Read more

PHP Notice: Undefined index: mytheme_meta_box_nonce

You should always check if a POST variable (or an item/key in an array like the superglobal $_POST variable) exists before attempting to use it. And you could use isset() like so: if ( // Check if the variable is set. isset( $_POST[‘mytheme_meta_box_nonce’] ) && // .. before accessing the value. ! wp_verify_nonce( $_POST[‘mytheme_meta_box_nonce’], basename( … Read more

Sizing textarea field in custom metabox

You could try styling it with CSS by adding an ID or a class to the textarea and inserting styles into the wp_admin head. Or, a quick way would be to do something like this : echo ‘<textarea name=”_dresscode” class=”widefat” style=”width:400px !important; height:80px !important;” >’ . $dresscode . ‘</textarea>’; If not, have you tried simply … Read more

Global custom meta box

In addition to the other answers, you can further improve it by looping through an array of types instead of manually adding a new add_meta_box() line each time you add a new type. $postTypes = array( ‘custom-post-type1’, ‘custom-post-type2’, ‘custom-post-type3’ ); foreach( $postTypes as $pt ) add_meta_box( ‘adv_form_box1’, ‘Advanced Form’, ‘adv_form1’, $pt, ‘side’, ‘high’ );