How To Remove The “+ Add New Category” Link From A Category Metabox

The default metaboxes are registred in the file wp-admin/includes/meta-boxes.php. There you can find the function post_categories_meta_box() which will generate the taxonomy metabox. Currently there is no hook available to filter the output. But you can do one of the following: Use remove_meta_box() to remove the existing category metabox and register your own with add_meta_box(). Copy&Past … Read more

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

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

Metabox with checkbox is not updating

Here is code I have used before – the main difference looks to me that you are checking if the meta exists rather than what it’s value is to determine if it should be checked. // Checkbox Meta add_action(“admin_init”, “checkbox_init”); function checkbox_init(){ add_meta_box(“checkbox”, “Checkbox”, “checkbox”, “post”, “normal”, “high”); } function checkbox(){ global $post; $custom = … Read more

Does WordPress have a “Form API”?

No, but it should 😉 There are several custom field class’s (backend). wpAlchemy : https://github.com/farinspace/wpalchemy Meta Box Script: https://github.com/rilwis/meta-box My-Meta-Box: https://github.com/bainternet/My-Meta-Box meta-box-class: https://github.com/corycrowley/meta-box-class Meta Boxes Class: https://github.com/Bakke/Wordpress-Custom-Meta-Boxes-Class For front-end forms, you probably best off with a plugin in Eugene Manuilov’s link.