I'm using the Exclude Pages From Navigation plugin to hide certain pages from the top drop down menu.
Is there a plugin or a way I can do the same with Categories?
I'm using the Exclude Pages From Navigation plugin to hide certain pages from the top drop down menu.
Is there a plugin or a way I can do the same with Categories?
Hi,
You can fulfill your requirement with with category tags. You need to use wp_list_categories tag with exclude option. Here is an example:
This will exclude category 7 and 13.
Try this...
Find the id of the categories you want to exclude (I'm sure there's an easy way to do this but I'm just returning to WP after a long time away!) - I browse the wp_terms table in the database, and note the ids of the categories you want to exclude.
THEN...
In the admin interface, go to edit 'header.php', search for wp_list_categories, and then just append "&exclude=x,y,z".
For example, in the template I'm using, my line in header.php looked like..
?php wp_list_categories('sort_column=name&title_li=&depth=2'); ?>
If I edit it so it looks like
?php wp_list_categories('sort_column=name&title_li=&depth=2&exclude=1,12'); ?>
Then it does exactly what I want.
Quick way of getting id's is to hover over them in the admin and look at the cat id in the URL shortcut.
hey, i tried this and it worked. problem is now i'm seeing the words "no categories" in my nav bar. is there a way to get rid of that?
Here is how...just put this on the top of your template...
<?php
function bm_dont_display_it($content) {
if (!empty($content)) {
$content = str_ireplace('<li>' .__( "No categories" ). '</li>', "", $content);
}
return $content;
}
add_filter('wp_list_categories','bm_dont_display_it');
?>This topic has been closed to new replies.