How to show posts from multiple WordPress categories on one search results page

1 August 2019

Following on from my recent post about filtering WordPress search results by category, here's how to show posts from multiple WordPress categories on one search results page.

To start the example, let's take one of the categories on this site:

(in case you were wondering, I've used the Yoast SEO plugin to remove the /categories/ prefix from my category page URLs, but that's not important here.)

Alternatively I can use the category ID as a URL parameter to get the same result:

You'll notice this URL automatically redirects to the first one.

Now it's actually possible to include two (or more) category IDs in the URL, comma separated like this:,31

This search results page will show posts from both category 41 (Domains and Hosting) AND category 31 (Social Media). Neat, huh!

Incidentally, the order of the IDs doesn't determine the order of the posts - the posts are listed, by default, in date order from newest to oldest. However, the first ID given determines the title of the page (both meta title and post title).

Notify of
Inline Feedbacks
View all comments
James Clark
Hi! I'm James Clark and this is my website. I publish all my guides completely free, so if you find them useful then please:
What do you think? Leave a commentx
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram