• 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.