WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
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? – sgwatstack May 16 '13 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 May 16 '13 at 18:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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