Include all your WordPress custom post types in search

What i love in WordPress 3.0+ is the fact that you can create as many custom post types as you want to properly separate your contents. And there’s something i see pretty often when when i’m working with people that use CPTs: their CPTs are not included in their search, and that’s big problem because some of them nearly don’t use posts but only CPTs, so here is a quick tip to explain you how you can automatically add your CPTs to your search. Adding WordPress custom post types in search has never been so easy.

Just add this code to your theme functions.php file or in any file of your plugins:

How to add WordPress custom post types in search

About the author

Remi Hey! My name is Rémi Corson, I'm a French WordPress Developer, I code stuff and I write from time to time ;-) Buy a coffee
Show your support

Related Posts


  1. AJ Clarke:

    Nice bit of code Remi ;)

  2. Monica:

    Awesome, this will come in handy, thanks :)

  3. bhavhirani:

    hi Rémi

    but can i include from my custom table in search ..?


Leave a Reply