Title: pre_get_posts() breaking permalinks
Last modified: August 21, 2016

---

# pre_get_posts() breaking permalinks

 *  [trunham](https://wordpress.org/support/users/trunham/)
 * (@trunham)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/pre_get_posts-breaking-permalinks/)
 * Hey guys,
 * The exact code is:
 *     ```
       function search_filter($query) {
         if ( !is_admin() && $query->is_main_query() ) {
            $query->set('post_type', array( 'post' ) );
         }
       }
       add_action('pre_get_posts','search_filter');
       ```
   
 * This appears to break all of my page links except for one which re-directs to
   a post for some reason. It happened after updating to 3.8 although i guess the
   code could be wrong too. Any help would be much appreciated!
 * Thanks

Viewing 1 replies (of 1 total)

 *  [Gary](https://wordpress.org/support/users/barnettgs/)
 * (@barnettgs)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/pre_get_posts-breaking-permalinks/#post-4442402)
 * This is already posted in [http://wordpress.org/support/topic/pre_get_posts-doenst-work-with-pretty-permalinks-anymore?replies=16](http://wordpress.org/support/topic/pre_get_posts-doenst-work-with-pretty-permalinks-anymore?replies=16)
 * Hope this helps

Viewing 1 replies (of 1 total)

The topic ‘pre_get_posts() breaking permalinks’ is closed to new replies.

## Tags

 * [breaking](https://wordpress.org/support/topic-tag/breaking/)
 * [breaks](https://wordpress.org/support/topic-tag/breaks/)
 * [pages](https://wordpress.org/support/topic-tag/pages/)
 * [permalink](https://wordpress.org/support/topic-tag/permalink/)
 * [permalinks](https://wordpress.org/support/topic-tag/permalinks/)
 * [pre get posts](https://wordpress.org/support/topic-tag/pre-get-posts/)
 * [pre_get_posts](https://wordpress.org/support/topic-tag/pre_get_posts/)
 * [updating](https://wordpress.org/support/topic-tag/updating/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Gary](https://wordpress.org/support/users/barnettgs/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/pre_get_posts-breaking-permalinks/#post-4442402)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
