Search a specific post type

Wpsnipp – If you would like to be able to control which posts or pages should be excluded from WordPress search results. WordPress gives you the ability to target specific post types. Adding this PHP cde to your wordpress theme will allow you to search specific post types.




function SearchFilter($query) {
if ($query->is_search) {
// Insert the specific post type you want to search
$query->set('post_type', 'feeds');
return $query;
// This filter will jump into the loop and arrange our results before they're returned

2 thoughts on “Search a specific post type

  1. Attractive section of content. I just stumbled upon your blog and in
    accession capital to assert that I get actually enjoyed account your
    blog posts. Any way I will be subscribing to your feeds and even
    I achievement you access consistently quickly.

Leave a comment