Remove a particular tag name from the tagcloud

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.

5 Answers
5

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.

Leave a Comment