lberelson

site 3 - function file

Jul 31st, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 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. function pagination($prev = '«', $next = '»') {
  25.         global $wp_query, $wp_rewrite;
  26.         $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
  27.         $pagination = array(
  28.             'base' => @add_query_arg('paged','%#%'),
  29.             'format' => '',
  30.             'total' => $wp_query->max_num_pages,
  31.             'current' => $current,
  32.             'prev_text' => __($prev),
  33.             'next_text' => __($next),
  34.             'type' => 'plain'
  35.     );
  36.         if( $wp_rewrite->using_permalinks() )
  37.             $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );
  38.      
  39.         if( !empty($wp_query->query_vars['s']) )
  40.             $pagination['add_args'] = array( 's' => get_query_var( 's' ) );
  41.      
  42.         echo paginate_links( $pagination );
  43. };
  44.      
  45.      
  46.    
  47.      
  48. /*
  49.     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.
  50. */
  51.      
  52. // add_filter('found_posts', 'myprefix_adjust_offset_pagination', 1, 2 );
  53.     function myprefix_adjust_offset_pagination($found_posts, $query) {
  54.      
  55.         //Define our offset again...
  56.         $offset = 10;
  57.      
  58.         //Ensure we're modifying the right query object...
  59.         if ( $query->is_posts_page ) {
  60.             //Reduce WordPress's found_posts count by the offset...
  61.             return $found_posts - $offset;
  62.         }
  63. }
  64.  
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment