Skip to main content

How to Make the WordPress Search Feature Work for You

Tue, Sep 27th, 2022

By following these simple tips, you can configure the WordPress search feature to work best for your website and its visitors.

The WordPress search feature is one of the most powerful tools you have at your disposal when it comes to managing your website. By adding a simple piece of code to your functions.php file, you can increase the number of results on your search archive page, making it easier for visitors to find what they’re looking for. I like to set my posts_per_page value to -1 to set the results to an infinite number, but you can experiment with different values to see what works best for you. Regardless of how you configure it, the WordPress search feature is a valuable asset that can make your site more user-friendly and easy to navigate.

function amdd_search_posts_per_page( $query) {
    if ( $query->is_search() && $query->is_main_query() && ! is_admin() ) {
        $query->set( 'posts_per_page', '-1' );
add_filter( 'pre_get_posts', 'amdd_search_posts_per_page' );