Advertisement
lberelson

site 3 - paginate instructors DEBUG

Jul 30th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. <?php
  2. /*
  3.  * Functions file
  4.  * Includes all necesary files
  5.  *
  6.  * @package custom
  7.  */
  8.  
  9.  
  10. function register_my_menus() {
  11.   register_nav_menus(
  12.     array(
  13.       'primary-menu' => __( 'Primary Menu' ),
  14.       'secondary-menu' => __( 'Secondary Menu' )
  15.     )
  16.   );
  17. }
  18. add_action( 'init', 'register_my_menus' );
  19.  
  20.  
  21. add_theme_support( 'post-thumbnails' );
  22.  
  23.    
  24.  
  25.     function pagination($prev = '«', $next = '»') {
  26.         global $wp_query, $wp_rewrite;
  27.         $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
  28.         $pagination = array(
  29.             'base' => @add_query_arg('paged','%#%'),
  30.             'format' => '',
  31.             'total' => $wp_query->max_num_pages,
  32.             'current' => $current,
  33.             'prev_text' => __($prev),
  34.             'next_text' => __($next),
  35.             'type' => 'plain'
  36.     );
  37.         if( $wp_rewrite->using_permalinks() )
  38.             $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );
  39.      
  40.         if( !empty($wp_query->query_vars['s']) )
  41.             $pagination['add_args'] = array( 's' => get_query_var( 's' ) );
  42.      
  43.         echo paginate_links( $pagination );
  44.     };
  45.      
  46.      
  47.    
  48.      
  49.     /*
  50.     WordPress makes a simple check to see if the number of pages outnumbers that query's posts_per_page property. However, while offset will skip posts in the loop, those skipped posts will still be counted when WordPress decides if there are more pages.
  51.     */
  52.      
  53.    // add_filter('found_posts', 'myprefix_adjust_offset_pagination', 1, 2 );
  54.     function myprefix_adjust_offset_pagination($found_posts, $query) {
  55.      
  56.         //Define our offset again...
  57.         $offset = 10;
  58.      
  59.         //Ensure we're modifying the right query object...
  60.         if ( $query->is_posts_page ) {
  61.             //Reduce WordPress's found_posts count by the offset...
  62.             return $found_posts - $offset;
  63.         }
  64.     }
  65.  
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement