Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Functions file
- * Includes all necesary files
- *
- * @package custom
- */
- function register_my_menus() {
- register_nav_menus(
- array(
- 'primary-menu' => __( 'Primary Menu' ),
- 'secondary-menu' => __( 'Secondary Menu' )
- )
- );
- }
- add_action( 'init', 'register_my_menus' );
- add_theme_support( 'post-thumbnails' );
- function pagination($prev = '«', $next = '»') {
- global $wp_query, $wp_rewrite;
- $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
- $pagination = array(
- 'base' => @add_query_arg('paged','%#%'),
- 'format' => '',
- 'total' => $wp_query->max_num_pages,
- 'current' => $current,
- 'prev_text' => __($prev),
- 'next_text' => __($next),
- 'type' => 'plain'
- );
- if( $wp_rewrite->using_permalinks() )
- $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );
- if( !empty($wp_query->query_vars['s']) )
- $pagination['add_args'] = array( 's' => get_query_var( 's' ) );
- echo paginate_links( $pagination );
- };
- /*
- 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.
- */
- // add_filter('found_posts', 'myprefix_adjust_offset_pagination', 1, 2 );
- function myprefix_adjust_offset_pagination($found_posts, $query) {
- //Define our offset again...
- $offset = 10;
- //Ensure we're modifying the right query object...
- if ( $query->is_posts_page ) {
- //Reduce WordPress's found_posts count by the offset...
- return $found_posts - $offset;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement