onetone_paging_nav

Display navigation to next/previous set of posts when applicable.

Description

onetone_paging_nav( (string) $echo = 'echo', (string) $wp_query = '' ); 

Parameters (2)

0. $echo — Optional. (string) => 'echo'
The echo.
1. $wp_query — Optional. (string) => ''
The wp query.

Usage

  1. if ( !function_exists( 'onetone_paging_nav' ) ) { 
  2. require_once '/includes/theme-functions.php'; 
  3.  
  4. // The echo. 
  5. $echo = 'echo'; 
  6.  
  7. // The wp query. 
  8. $wp_query = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = onetone_paging_nav($echo, $wp_query); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/theme-functions.php  
  1. function onetone_paging_nav($echo='echo', $wp_query='') { 
  2.  
  3. if(!$wp_query) {global $wp_query;} 
  4. global $wp_rewrite;  
  5. $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1; 
  6.  
  7. $pagination = array( 
  8. 'base' => @add_query_arg('paged', '%#%'),  
  9. 'format' => '?page=%#%',  
  10. 'total' => $wp_query->max_num_pages,  
  11. 'current' => $current,  
  12. 'show_all' => false,  
  13. 'end_size' => 1,  
  14. 'mid_size' => 2,  
  15. 'prev_next' => true,  
  16. 'prev_text' => __(' Prev', 'onetone'),  
  17. 'next_text' => __('Next ', 'onetone'),  
  18. 'type' => 'list',  
  19. 'add_args' => false,  
  20. 'add_fragment' => '',  
  21. 'before_page_number' => '',  
  22. 'after_page_number' => '' 
  23. ); 
  24.  
  25. if( $wp_rewrite->using_permalinks() ) 
  26. $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg('s', get_pagenum_link(1) ) ) . 'page/%#%/', 'paged'); 
  27.  
  28. if( !empty($wp_query->query_vars['s']) ) 
  29. $pagination['add_args'] = array('s'=>get_query_var('s')); 
  30.  
  31. if( $wp_query->max_num_pages > 1 ) { 
  32. if($echo == "echo") { 
  33. echo '<nav class="post-list-pagination" role="navigation"> 
  34. <div class="post-pagination-decoration text-center"> 
  35. '.paginate_links($pagination).'</div></nav>';  
  36. }else 
  37.  
  38. return '<nav class="post-list-pagination" role="navigation"> 
  39. <div class="post-pagination-decoration text-center">'.paginate_links($pagination).'</div></nav>'; 
  40.