Query to Hide WordPress Category from Category List

You may have many categories in to WordPress post. But you don’t want to show certain categories or hide some to show in front-end category list. You can do this adding a simple function. After hiding these categories you can still access these from front-end if you know the category link or permalink. So if you want to hide a category then simply named it differently so that users can’t guess the name easily. Now lets learn the query to hide WordPress category from category list.

hide-category-in-wordpress

First of all find out all the ID’s of categories you want to hide from admin panel. If you are a newbie and don’t know how to fine category ID then go to Post->Categories menu and see the following image:

find-cat-id-in-wp

Then after finding the categories ID the add the following function to your functions.php file:

[php]

function exclude_widget_categories($args){
$exclude = "3,13,32";
$args["exclude"] = $exclude;
return $args;
}
add_filter("widget_categories_args","exclude_widget_categories");

[/php]

Now User cannot see the category associated with ID 3,13 and 32.

 

Author: mytutorialguru

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *