Add default WordPress tag meta box to User Profile

This code works for me. It uses ‘locations’ custom taxonomy and ‘suggest’ javascript. You need to extend it to support multiple term selection. Add custom field to user-edit screen and store metadata when user/admin updates profile // for account owner add_action(‘show_user_profile’, ‘add_custom_user_profile_fields’); add_action(‘personal_options_update’, ‘save_custom_user_profile_fields’); // for admins add_action(‘edit_user_profile’, ‘add_custom_user_profile_fields’); add_action(‘edit_user_profile_update’, ‘save_custom_user_profile_fields’); function add_custom_user_profile_fields($user) { printf( … Read more

Meta Boxes: ‘admin_init’ or ‘add_meta_boxes’ hook?

Have a look at this list: http://codex.wordpress.org/Plugin_API/Action_Reference It doesn’t matter which one you use as long as it’s not too early and not too late. It’s best to use intuitive and predictable hooks, so add_meta_boxes is preferred. Someday in the future WordPress may change something and by using the most appropriate hooks you increase your … Read more

Taxonomy dropdown metabox in the back-end

Here is an example. I have also created a Gist with more generic code. add_action(‘add_meta_boxes’, ‘my_custom_metabox’); function my_custom_metabox() { add_meta_box(‘custom-taxonomy-dropdown’,’Brands’,’taxonomy_dropdowns_box’,’post’,’side’,’high’); } function taxonomy_dropdowns_box( $post ) { wp_nonce_field(‘custom-dropdown’, ‘dropdown-nonce’); $terms = get_terms( ‘brands’, ‘hide_empty=0’); $object_terms = wp_get_object_terms( $post->ID, ‘brands’, array(‘fields’=>’ids’)); // you can move the below java script to admin_head ?> <script type=”text/javascript”> jQuery(document).ready(function() { jQuery(‘#custombrandoptions’).change(function() … Read more

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