WordPress Search Syntax in URL for Custom Post Types

Home/WordPress Search Syntax in URL for Custom Post Types

WordPress isn’t exactly Google when it comes to searching. The system is long overdue an overhaul, but while we wait for the never-arriving necessity you can still get much more out of your WordPress searches.

Today a programmer client asked me something that I thought most WordPress developers would know without question:

How do I search a custom post type using the default WordPress /?s=

[searchterm] string in the URL bar?

The answer isn’t that difficult at all, but I’ll note it for reference. All you actually need is to add another variable to the URL, like so:

http://www.webprogrammer.co.uk/?s=programming&post_type=website-developers

Voila! The ability to search custom post types and also create your own simple search box for them using the GET or POST variables in the URL.

2017-05-19T15:48:04+00:00 January 25th, 2015|WordPress, WordPress Snippets|0 Comments

About the Author:

Warren Chandler is a freelance web programmer and web developer, based in Frinton on Sea, Essex. Warren specialises in web programming, web design, corporate identity, copy writing, SEO, logo and print media for home, work, and mobile platforms.

Leave A Comment