Hi,
Instead of using a plugin, you could create a function to store all the categories you wish to exclude, and then reference it in the ‘exclude’ argument of the wp_list_categories
function, which is WordPress function. This would list all your categories except for the ones stored in the exclusion function.
Here’s a very simple way of doing this:
1. Paste the following code into your theme’s functions.php file:
function userf_cat_exclusion_list() {
$exclusion_list = '';
return $exclusion_list;
}
2. Add all the category IDs you wish to exclude in the second line. Ex.:
$exclusion_list = '1,3,4,8';
3. Use the wp_list_categories function to display your categories and call the userf_cat_exclusion_list
in the exclude
parameter like so:
<?php wp_list_categories(array(
'exclude' => userf_cat_exclusion_list(),
));
?>
You can add other arguments to the function, but you need to do so before ));
. Example:
<?php wp_list_categories(array(
'exclude' => userf_cat_exclusion_list(),
'order<code>=></code>DESC
,
‘title_li’ = ”
));
?>
This way, you won't have to copy/paste the category IDs in the <code>exclude</code> argument every time you call the wp_list_categories
function, which is rather helpful if you wish to exclude many categories.
I hope this helps!
`