Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How do I remove a particular tag name from the tag cloud ?

I changed wp-includes/default-widgets.php on line 1038 from

wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) );

to

wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy, 'exclude' => "featured") ) );

But no effect.

share|improve this question

3 Answers 3

First: Don’t touch the core files, they will be overwritten during the next update.

There is already an argument for exclusions available: exclude. It expects a term id.

Sample:

wp_tag_cloud(
    array (
        'exclude' => 54
    )
);

Sometimes you don’t know the ID, but you can get it if you know the slug:

$args = array ();
$ex_term = get_term_by( 'slug', 'chattels', 'post_tag' );

if ( ! empty ( $ex_term ) && ! is_wp_error( $ex_term ) )
    $args['exclude'] = $ex_term->term_id;

wp_tag_cloud( $args );

See the Codex page for more parameters.

share|improve this answer
    
This works well if calling the wp_tag_cloud() function directly, but not if using the Tag Cloud widget –  bungeshea Dec 25 '12 at 21:40

Modifying core files is not recommended as they will be overwritten in the next upgrade. Fortunately, you can use the power of filters to make the change you need.

The reason why your hack didn't work is because you need to pass the tag id to the function, not the name.

This code will modify the tag cloud args to exclude the tag with the 'featured' slug. Paste this code to your active theme's functions.php file, a custom plugin, or as a code snippet:

add_filter( 'widget_tag_cloud_args', 'my_tag_cloud_args' );

function my_tag_cloud_args( $args ) {
    $args['exclude'] =  get_term_by( 'slug', 'featured', 'post_tag' );
    return $args;
}
share|improve this answer

You are passing name, you ll need to pass ID of that tag.

wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy, 'exclude' => "5") ) );

share|improve this answer

Your Answer

 
discard

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.