Title: Altering Search Form
Last modified: August 31, 2016

---

# Altering Search Form

 *  [wrdslngr](https://wordpress.org/support/users/wrdslngr/)
 * (@wrdslngr)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/altering-search-form/)
 * How do you alter search results? My theme wants it paginated. I would really 
   prefer it all came in as a list

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Justin Tucker](https://wordpress.org/support/users/certainstrings/)
 * (@certainstrings)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/altering-search-form/#post-7027316)
 * You can add a filter to your functions.php file that sets parameters before posts
   are requested from the database. However, setting posts to -1 is generally not
   a good idea, especially for search for results. If you have a significant amount
   of posts, you could crash your site. Ideally you should set a high number (500?)
   and paginate from there.
 * You can read more about that here:
    [https://10up.github.io/Engineering-Best-Practices/php/#performance](https://10up.github.io/Engineering-Best-Practices/php/#performance)
 * If you’re using a free or purchased theme, make sure you create a child theme.
 *     ```
       function search_filter($query) {
   
            // make sure we're not on the admin and we are in the main query
            if ( !is_admin() && $query->is_main_query() ) {
                // only set the post parameter if we're searching for posts
                if ($query->is_search) {
                    $query->set('posts_per_page', -1);
                }
            }
       }
   
       add_action('pre_get_posts','search_filter');
       ```
   
 *  Thread Starter [wrdslngr](https://wordpress.org/support/users/wrdslngr/)
 * (@wrdslngr)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/altering-search-form/#post-7027452)
 * Thanks. I’ll so some research.
 * If you want to see what it does, go to [http://www.chattahoocheetech.edu](http://www.chattahoocheetech.edu)
   and run a search.
 * Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Altering Search Form’ is closed to new replies.

## Tags

 * [search results](https://wordpress.org/support/topic-tag/search-results/)

 * 2 replies
 * 2 participants
 * Last reply from: [wrdslngr](https://wordpress.org/support/users/wrdslngr/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/altering-search-form/#post-7027452)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
