How to filter WordPress search by custom post type

Add the input hidden field

If you want to limit the WordPress search to a specific custom post type, add a hidden input field with that post type:


This is a form with a search input field and a hidden field which will filter the results only for my "books" custom post type:

Leave a Reply

Add <code> Some Code </code> by using this tags.