Sunday, 18 August 2013

How to intercept/edit the_category?

How to intercept/edit the_category?

In WordPress functions.php, how would I grab the_category() output before
it displays and unset some number of categories and URLs in its output?
I use some number of categories to help organize my category structure, to
make it easier to find and use categories when creating content. But I
don't want these "helper" categories to display wherever the_category() is
called in my site.
Because the number of these helper categories is large and somewhat likely
to expand, while the descriptive categories I want to use and display is a
small data set, ideally I'd like to grab the_category() results before it
is displayed, in the functions.php file, and remove any categories not
defined. So I might have an array of 10 descriptive category names and
their URLs. Then do a comparison with the_category() data and remove any
category names and URLs from the_category() output NOT in my array of 10
categories.
Is this do-able? Thanks for any ideas!

No comments:

Post a Comment