PageRenderTime 64ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/templates/loop/result-count.php

https://github.com/CammoKing/woocommerce
PHP | 32 lines | 18 code | 5 blank | 9 comment | 3 complexity | 79ea942b647a185b3142e9b993baf0fe MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /**
  3. * Result Count
  4. *
  5. * Shows text: Showing x - x of x results
  6. *
  7. * @author WooThemes
  8. * @package WooCommerce/Templates
  9. * @version 1.7
  10. */
  11. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  12. global $woocommerce, $wp_query;
  13. if ( ! woocommerce_products_will_display() )
  14. return;
  15. ?>
  16. <p class="woocommerce_result_count">
  17. <?php
  18. $paged = max( 1, $wp_query->get( 'paged' ) );
  19. $per_page = $wp_query->get( 'posts_per_page' );
  20. $max = $wp_query->found_posts;
  21. $first = ( $per_page * $paged ) - $per_page + 1;
  22. $last = $wp_query->get( 'posts_per_page' ) * $paged;
  23. if ( $last > $max )
  24. $last = $max;
  25. printf( __( 'Showing %s - %s of %s results', 'woocommerce' ), $first, $last, $max );
  26. ?>
  27. </p>