Limit search form to 4 custom post types only

I’m able to limit the search to one post type which works like a charm.

This code works: <input type="hidden" name="post_type" value="videos"/>

However, how do I limit the search to be performed in 4 custom post types instead of just one.

The post types are “videos, e-courses, e-books and white-papers”.

Any help is really appreciated.

Thanks

1 Answer
1

You have to change the input with 4 inputs like this :

<input type="hidden" name="post_type[]" value="videos" />
<input type="hidden" name="post_type[]" value="e-courses" />
<input type="hidden" name="post_type[]" value="e-books" />
<input type="hidden" name="post_type[]" value="white-papers" />

You may get more detail about a complete code in this article

Leave a Comment