WordPress : How to have query search posts only

If you need to have your WordPress search only search posts for results, you can insert this code before the ‘if(have_posts()):’ line on search.php and it will do that for you.

Further to that you can add any arguments from the standard WP_Query function to there to make the search more custom 🙂