Exclude taxonomy from tag cloud widget

As is described in title, let’s find out how to exclude specific taxonomies from displaying in tag cloud widget by ID. If you don’t know what’s the ID of unwanted taxonomy,  and you don’t know how to find it, follow these steps, otherwise skip to step 2:

Step 1:

  • open you’re worpdress admin area
  • choose wanted taxonomy (or category, post, tag… it’s the same technique for all)
  • on list, hover above wanted taxonomy with mouse, and in bottom of your browser you’ll see full permalink, inside that permalink there is ID of your taxonomy (or post or page or category….)
  • if you want to exclude multiple taxonomy, write down on paper (notepad :)) each taxonomy ID, or remember it 😉
  • see image for example:

wp_id_hover

Now, when you have ID’s (in our case it’s 13), we can call it in various php functions.

 

Step 2:

  • open your functions.php, through wp-admin/appearance/editor, or directly via FTP…
  • before closing php tag (?>) add this line of code:
function exclude_tag_cloud_widget($args) {
$args['exclude'] = array(13); //exclude tags by ID
return $args;
}
add_filter( 'widget_tag_cloud_args', 'exclude_tag_cloud_widget' );
  • as you see, we created new function and we put unwanted ID in array. If you want to put multiple ID’s separate it with comma like this: array(13, 12, 1)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s