How to make open/closed and hidden/shown metaboxes status saved on a per-post basis?

The Main Problem: The main problem here is that in the closing-, hiding- and ordering- ajax calls, there’s no post ID sent with the payload. Here are two form data examples: 1) action:closed-postboxes closed:formatdiv,tagsdiv-post_tag,trackbacksdiv,authordiv hidden:slugdiv closedpostboxesnonce:8723ee108f page:post 2) action:meta-box-order _ajax_nonce:b6b48d2d16 page_columns:2 page:post order[side]:submitdiv,formatdiv,categorydiv,tagsdiv-post_tag,postimagediv order[normal]:postexcerpt,postcustom,trackbacksdiv,commentsdiv,authordiv order[advanced]: We could get around this by using another custom ajax … Read more

WordPress SEO by Yoast: Hide Meta Boxes in Posts for Non-admins

It didn’t say in the API docs on the Yoast SEO plugin site what the ID was and I don’t have a copy of Yoast at installed at disposal, but according to yoas-plugin-dir/admin/class-metabox.php line 144, the meta_box registered is; add_meta_box( ‘wpseo_meta’, …etc ); … Which is hooked onto add_meta_boxes hook on line 32 of the … Read more

Change The Title Of a Meta Box

Improved Answer I’ve decided to revisit this question after realising how unnecesarily hacky it is. The the best solution is to to remove the metabox, and then re-add it, specifying an alternative title. Here’s an example for the post post-type. add_action( ‘add_meta_boxes_post’, ‘wpse39446_add_meta_boxes’ ); function wpse39446_add_meta_boxes() { remove_meta_box( ‘authordiv’, ‘post’, ‘core’ ); add_meta_box( ‘authordiv’, __(‘Team … Read more

Removing panels (meta boxes) in the Block Editor

The remove_meta_box() function will not work with the Block Editor, because these are now Panels and work differently. There is currently no documentation on how to disable Panels, but, let’s dance. We want to avoid hiding panels via CSS, and rely on the JS API. We need to use the JS function removeEditorPanel() which will … Read more

Setting admin edit panels & metaboxes positions and visibility for ALL users and admins

You can remove the default meta boxes with remove_meta_box and re-add them in a different position with add_meta_box: add_action(‘do_meta_boxes’, ‘wpse33063_move_meta_box’); function wpse33063_move_meta_box(){ remove_meta_box( ‘postimagediv’, ‘post’, ‘side’ ); add_meta_box(‘postimagediv’, __(‘Featured Image’), ‘post_thumbnail_meta_box’, ‘post’, ‘normal’, ‘high’); } The answer above is from the following thread: How to change default position of WP meta boxes? UPDATE If the … Read more

What is the “Advanced” $context in add_meta_box?

The difference between normal and advanced is that normal will be placed on the page before advanced. For example the following will display “One” before “Two” function admin_init_test() { add_meta_box(‘one’, __(‘One’), ‘test_one’, ‘post’, ‘advanced’); add_meta_box(‘two’, __(‘Two’), ‘test_two’, ‘post’, ‘normal’); } add_action(‘admin_init’, ‘admin_init_test’); function test_two() { echo “<p>test_two</p>”; } function test_one() { echo “<p>test_one</p>”; } If … Read more

How to HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button

You can simply hide the options using CSS. This will add a display:none style to the misc and minor publishing actions on the post.php and post-new.php pages. It checks for a specific post type as well since all post types use these two files. function hide_publishing_actions(){ $my_post_type=”POST_TYPE”; global $post; if($post->post_type == $my_post_type){ echo ‘ <style … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)