Filter Posts by Multiple Categories in WordPress

At the top of the All Posts page inside the WordPress dashboard there is a drop-down which allows us to filter the posts shown based on the category they’re in. This option however useful has one glaring limitation: we can only filter one category at a time.

The option is therefore unhelpful in scenarios where we may want to show posts under multiple categories or posts contain two or more categories. Fortunately, we can still filter the posts using the same workaround I outlined in filtering WordPress posts by tags.

What’s more, we don’t need to install any plugin to do this but instead only need to edit and load URLs in a specific pattern. Here’s how to go about it.

Advertisements

Edit URL to Filter Posts under Multiple Categories

  1. Login into your WordPress Dashboard and go to the All Posts page.
  2. On your address bar type the URL in the following format and press enter:
https://www.yourdomain.com/wp-admin/edit.php?category_name=category1,category2,category3

This URL will show posts that have ANY of the three categories as the commas represent an OR operand. Edit the URL appropriately according to the number of categories you need to filter.

  1. To show posts that have two or more categories replace the comma with a plus:
https://www.yourdomain.com/wp-admin/edit.php?category_name=category1+category2

This URL will ONLY show posts that have both categories as the plus sign here represents the AND operand.

Filtering Categories with Multiple Words

For any category that has two or more words make sure to separate the individual words using a hyphen i.e.

https://www.yourdomain.com/wp-admin/edit.php?category_name=category-one

So for instance if we need to show all posts that are in the category Android and Windows Mobile, the URL would look as follows:

https://www.yourdomain.com/wp-admin/edit.php?category_name=Android,Windows-Phone

On the other hand, to show posts that have both the Android and Windows Phone categories, we would load the following URL:

https://www.yourdomain.com/wp-admin/edit.php?category_name=Android+Windows-Phone

I hope that’s clear. If not, please refer to the video tutorial from my YouTube channel that I’ve embedded at the start of the steps. A subscribe or like would also be much appreciated!

Tags:

Leave a Reply

Feel free to share your comments or questions with me. I may not be able to respond immediately so please check later once I've approved your comment.

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