I used the information posted on this blog post to display specific tags when editing a post. The editors on my site wanted the ability to display pre-specified tags instead of the most popular ones. We have a lot of tags and sometimes the ones they want to use are not being used because they are not seen and they don't remember what to search for.

So in the wp-admin/includes/ajax-actions.php file I changed the line 651 to

$tags = get_terms( $taxonomy, array( 
    'number' => 45, 
    'orderby' => 'name', 
    'order' => 'DESC', 
    'include' => array('21', '12') 
) );

where the include array is the selection of tags I want to display.

and line 665 to

$return = wp_generate_tag_cloud( $tags, array(
    'largest' => 10, 
    'smallest' => 10, 
    'filter' => 0, 
    'format' => 'flat', 
    'separator' => "  "
) );

This works fine for displaying a sequential list (I didn't want a tag cloud) of specific tags but these changes are to the wordpress core and on the next update I'll have to go in and re-do these. Is there any way to accomplish this with hooks so that I don't mess with the core?


1 Answer 1


We can override the Ajax call to wp_ajax_get_tagcloud() and do a clean hack.

/* Plugin Name: Custom Admin Tag Cloud */

add_action( 'wp_ajax_get-tagcloud', 'ajax_tag_cloud_wpse_99497', 1 );

function ajax_tag_cloud_wpse_99497() 
    // http://core.trac.wordpress.org/browser/tags/3.5.1/wp-admin/includes/ajax-actions.php#L639

Restore your core files to its original state, copy the modified function inside the above container and create a plugin for it. And ready to go.

  • Thanks, that worked just fine. Additionally, if I wanted to override something like post_tags_meta_box from wp-admin/includes/meta-boxes.php, I could use this same method in my functions file? Commented May 16, 2013 at 17:18
  • Does it involve any Ajax? If not and depending on what you want to do, you have to unset the meta box and create a modified clone. Also, search the core file you're interested for available hooks: do_action and apply_filters. . . . PS: don't mis-use the functions file, see wordpress.stackexchange.com/q/73031/12615
    – brasofilo
    Commented May 16, 2013 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.