How to change the number of search results in WordPress

In this article, you will learn how to change the number of search results WordPress displays upon a blog page search. We will change this using your cPanel account as people have the theme editor disabled for security reasons.

How to change the number of search results in WordPress using cPanel #

To change the number of search results displayed follow these steps:

  1. Log in to your cPanel account.
  2. Search for file manager then click it.
  3. Open your WordPress installation (usually public_html) then navigate to the following wp-content/themes/[your current theme].
  4. Find the functions.php, right-click, edit.
  5. Paste the following code at the very bottom.
    function control_search_results() {
    if ( is_search() )
    set_query_var(‘posts_per_archive_page’, 15); // Change number 15 to how many search results
    }
    add_filter(‘pre_get_posts’, ‘control_search_results’);
  6. Press save in the top right.
  7. Go to your wordpress site and check the code is working correctly.

Changing functions. Php file in cpanel for wordpress search results conor bradley digital agency

[rev_slider alias=”Conor-Bradley-Digital-Agency-knowledge-base-bottom-footer”][/rev_slider]

 Facebook | Twitter | Instagram | LinkedIn  | Youtube | Vimeo | Blog | Knowledge Base | Client Area | Google Business

Updated on July 23, 2021