Guest User

Untitled

a guest
Nov 17th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. //search.php
  2. echo '<a href="'. add_query_arg( 'count', '10' ) .'" title="View 10 posts per page">10</a>';
  3. echo '<a href="'. add_query_arg( 'count', '50' ) .'" title="View 50 posts per page">50</a>';
  4. echo '<a href="'. add_query_arg( 'count', '100' ) .'" title="View 100 posts per page">100</a>';
  5.  
  6. //functions.php
  7. function wds_btc_limit_search_posts() {
  8. if ( is_search() ) {
  9. switch($_GET['count']) {
  10. case '50':
  11. $_SESSION['search_count'] = $_GET['count'];
  12. break;
  13. case '100':
  14. $_SESSION['search_count'] = $_GET['count'];
  15. break;
  16. default:
  17. $_SESSION['search_count'] = '10';
  18. }
  19. $limit = $_SESSION['search_count'];
  20. }
  21. set_query_var( 'posts_per_page', $limit );
  22. }
  23. add_filter('pre_get_posts', 'wds_btc_limit_search_posts');
Add Comment
Please, Sign In to add comment