How to Filter WordPress Categories from the_category()

On this blog, I have shared various WordPress tips and hacks in past. If you are new to WordPress, I recommend you to read the collection of WordPress tutorials. This post is the addition of a new WordPress top in that collection. In this post, I will explain Hhow to Filter WordPress Categories from the_category()

In WordPress, the_category() function is used to display all categories of a specific post. It automatically prints all categories associated with a post. You can also select a separator for printed categories by passing in the function. If you want a comma separated, use the code added below:

In WordPress, the_category() function is used to display all categories of a specific post. It automatically prints all categories associated with a post. You can also select a separator for printed categories by passing in the function. If you want a comma separated, use the code added below:

But sometimes, you do not want to display all posts. Few days back, I had the same requirement when I want to hide a specific category from posts. I achieved that by adding a filter to the_category() function. I found this useful code on pcunleashed.com This code works fine and you can filter one or more categories. See in the code, it added filter for categories ‘Mac and ‘Windows’. You can change it as per your own requirement.

Add this code in the function.php of your theme or create a site-wide plugin to make this code universal.

If you have similar kind of need, you can use this code on your website.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest updates, web design resources and tools.

You have Successfully Subscribed!

About The Author

  • ADD YOUR COMMENT

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Receive fresh web design resources and SEO tips in your email by our weekly newsletter

You have Successfully Subscribed!

Pin It on Pinterest

Share This

Share This

Share this post with your friends!