Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created March 5, 2019 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/6771a74ee50455e66cc9e171282fba27 to your computer and use it in GitHub Desktop.
Save billerickson/6771a74ee50455e66cc9e171282fba27 to your computer and use it in GitHub Desktop.
<?php
/**
* Search 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>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment