Search Results Heading

Use this for the “Showing 1-10 of 20 results” text above the listing.

/** * Search Heading * @link https://www.billerickson.net/code/search-results-heading/ */ function ea_search_results_heading() { global $wp_query; $paged = get_query_var( 'paged') ? get_query_var( 'paged' ) : 1; $per_page = get_query_var( 'posts_per_page' ); $start = 1 + $per_page * ( $paged - 1 ); $end = $start + $per_page - 1 > $wp_query->found_posts ? $wp_query->found_posts : $start + $per_page - 1; $output = 'Showing ' . $start . '-' . $end . ' of ' . $wp_query->found_posts . ' results'; echo '<div class="search-count">' . $output . '</div>'; }

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk