I have created some functional categories that I use to show/hide markup elements. However, when I go to list the legit categories, these show up too, which I would expect. I want to list the legitimate categories and omit others.
I need to know how you would do it under two circumstances….
1) Each category that I want to exclude is preceded by an underscore character in its name.
2) Each category that I want to exclude is NOT preceeded by a special character and I will just provide an ID to the script that handles the exclusion listing.
A check over at the codex for the wp_list_categories template tag (http://codex.wordpress.org/Template_Tags/wp_list_categories) describes three parameters of
wp_list_categories()that allow you to control the inclusion or exclusion of categories.You might have checked this already, and maybe you are looking for a more dynamic way to exclude categories with the prefix you describe.
A: you could hard-code the categories you want to exclude in your call to
wp_list_categories().B: you could write a function that loops through the category names (using
get_categories()and create a comma separated string of of the category id’s thatpreg_match()the prefix you designated. Pass the string to wp_list_categories argument under the exclude parameter.