How to filter WordPress search results by category

24 July 2019

This post could just as easily be called 'how to filter a WordPress category page by keyword search term'!

Anyway here is a standard WordPress search page URL (in this case for the keyword 'count'). It shows results from all categories:

https://www.technicallyproduct.co.uk?s=count

And here is a WordPress category page URL (for the category 'web development'). It shows all posts in that category:

https://www.technicallyproduct.co.uk/web-development

It is possible to combine the two. So the following URL only shows posts within the 'web development' category that also include the word 'count':

https://www.technicallyproduct.co.uk/web-development?s=count

It is also possible to use the category ID in the URL instead and get the same results:

https://www.technicallyproduct.co.uk/?cat=13&s=count

I recently used this technique on a client's classifieds website to generate quite specific browse pages in lieu of having a complex taxonomy.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
James Clark
Hi! I'm James Clark and this is my website. Need help with your own website's analytics, SEO, content or ads? Contact me
Copyright © James Clark
0
What do you think? Leave a commentx
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram