Title: Error with pre_get_posts
Last modified: August 30, 2016

---

# Error with pre_get_posts

 *  [xr0m3oz](https://wordpress.org/support/users/xr0m3oz/)
 * (@xr0m3oz)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/error-with-pre_get_posts/)
 *     ```
       function search_filter($query) {
   
       	if (is_search()) {
       		$query->set('post_parent__not_in', array(560));
       		$query->set('posts_per_page', -1);
       	}
   
       	return $query;
       }
   
       add_action( 'pre_get_posts', 'search_filter' );
       ```
   
 * File function.php
 * Nothing happens, the changes are not present. What could be the problem?
    If 
   you insert exit() in check it works.

The topic ‘Error with pre_get_posts’ is closed to new replies.

## Tags

 * [function.php](https://wordpress.org/support/topic-tag/function-php/)
 * [pre_get_posts](https://wordpress.org/support/topic-tag/pre_get_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [xr0m3oz](https://wordpress.org/support/users/xr0m3oz/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/error-with-pre_get_posts/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
