Search only post type wordpress

By default wordpress search provides an searching function on whole site whether it is pages or post type. In order to make the search only post type in wordpress, below is the code you need to copy and paste it in to your function.php file. Search only post type function filter_search($query) { if ($query->is_search) { […]