Category list on sidebar widget will display all categories on post category hierarchy by default. However, we do not want to display all of them for some reason. Here is simple technique to achieve this goal.
Table of Contents
Find category IDs
First thing to do is to find out all category IDs that we don't want them to show on the sidebar. Run the following script against WordPress MySQL database.
SELECT t.term_id catID,t.name FROM wp_terms t
join wp_term_taxonomy tax on tax.term_id=t.term_id
//Hide categories from WordPress category widget
$exclude = "4,6,7,8,9,10,13,14,15,16";
$args["exclude"] = $exclude;
Apply the snippets
There are many ways to apply the snippets. You could add it to theme functions.php file or using snippets plugin to apply the snippets code. In my case, I'm using snippets to apply the code. This way is better organized for reusing the snippets.
Last words, This is the simplest way to contorl the category list on sidebar, but you may use other ways to control the category list on sidebar, for instance, find a proper plugin or write your own plugin to achieve it.