Title: Excluding / including search results (function.php)
Last modified: August 19, 2016

---

# Excluding / including search results (function.php)

 *  [scooly](https://wordpress.org/support/users/scooly/)
 * (@scooly)
 * [18 years ago](https://wordpress.org/support/topic/excluding-including-search-results-functionphp/)
 * functions.php
 * It works:
 *     ```
       function search_exclude($query)
       {
       if ($query->is_search)
       {
       $query->set('p','52');
       }
       return $query;
       }
       add_filter('pre_get_posts','search_exclude');
       ```
   
 * It doesn’t work:
 *     ```
       function search_exclude($query)
       {
       if ($query->is_search)
       {
       $query->set('p','52,53');
       }
       return $query;
       }
       add_filter('pre_get_posts','search_exclude');
       ```
   
 * If I’m doing something wrong?

The topic ‘Excluding / including search results (function.php)’ is closed to new
replies.

 * 0 replies
 * 1 participant
 * Last reply from: [scooly](https://wordpress.org/support/users/scooly/)
 * Last activity: [18 years ago](https://wordpress.org/support/topic/excluding-including-search-results-functionphp/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
