Table of Contents
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:
- Log in to your cPanel account.
- Search for file manager then click it.
- Open your WordPress installation (usually public_html) then navigate to the following wp-content/themes/[your current theme].
- Find the functions.php, right-click, edit.
- 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’); - Press save in the top right.
- Go to your wordpress site and check the code is working correctly.
Facebook | Twitter | Instagram | LinkedIn | Youtube | Vimeo | Blog | Knowledge Base | Client Area | Google Business