Site icon T4Tutorials.com

Desired numbers of search results in one search page

By default, mostly WordPress has 10 results on the search page when we search a keyword. Let me tell you “How to show Desired numbers of search results in one search page”?

Step 1: Go to the admin dashboard

Step 2: Select Appearance

Step 3: Select the Theme file editor

Step 4: Open functions.php

Step 5: Add the following code at the bottom of functions.php

function custom_search_results_per_page( $query ) {
  if ( $query->is_search ) {
    $query->set( 'posts_per_page', 50 ); // Change 10 to the number of results you want to display
  }
}
add_action( 'pre_get_posts', 'custom_search_results_per_page' );
Desired numbers of search results in one search page of WordPress

 

Exit mobile version