Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
- $fp_limit = 3; // first page limit
- $limit = 2; // following page limit
- $offset = 0; // default offset
- if( $paged == 1 ) {
- $limit = $fp_limit;
- } else {
- $offset = $fp_limit + ( ($paged - 2) * $limit );
- }
- $args = array(
- 'post_type' => 'my_post_type',
- 'post_status' => 'publish',
- 'offset' => $offset,
- 'posts_per_page' => $limit,
- 'caller_ get_ posts' => -1, // remove sticky post
- 'paged' => $paged,
- 'tax_query' => array(
- array(
- 'taxonomy' => 'my_taxo',
- 'field' => 'slug',
- 'terms' => array('slug1', 'slug2', 'slug3')
- )
- )
- );
- $my_query = null;
- $my_query = new WP_Query($args);
- // basic loop
- if( $my_query->have_posts() ) :
- while ($my_query->have_posts()) : $my_query->the_post();
- ...
- endwhile; endif; // archive loop
- if (function_exists('wp_pagenavi')){ wp_pagenavi( array( 'query' => $my_query ) ); }
- wp_reset_query();
- <?php
- if ( have_posts() ) :
- // Start the Loop.
- while ( have_posts() ) : the_post();
- ///<---YOUR LOOP--->
- endwhile;
- //<---YOUR PAGINATION--->
- else :
- //NO POSTS FOUND OR SOMETHING
- endif;
- ?>
- $ppg = get_option('posts_per_page');
- $offset = 1;
- $query->set('posts_per_page', $offset + $ppp);
- $offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );
- $query->set('posts_per_page',$ppp);
- $query->set('offset',$offset);
- function homepage_offset_pagination( $found_posts, $query ) {
- $offset = 1;
- if( $query->is_home() && $query->is_main_query() ) {
- $found_posts = $found_posts - $offset;
- }
- return $found_posts;
- }
- add_filter( 'found_posts', 'homepage_offset_pagination', 10, 2 );
- function tax_and_offset_homepage( $query ) {
- if ($query->is_home() && $query->is_main_query() && !is_admin()) {
- $query->set( 'post_type', 'my_post_type' );
- $query->set( 'post_status', 'publish' );
- $query->set( 'ignore_sticky_posts', '-1' );
- $tax_query = array(
- array(
- 'taxonomy' => 'my_taxo',
- 'field' => 'slug',
- 'terms' => array('slug1', 'slug2', 'slug3')
- )
- );
- $query->set( 'tax_query', $tax_query );
- $ppp = get_option('posts_per_page');
- $offset = 1;
- if (!$query->is_paged()) {
- $query->set('posts_per_page',$offset + $ppp);
- } else {
- $offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );
- $query->set('posts_per_page',$ppp);
- $query->set('offset',$offset);
- }
- }
- }
- add_action('pre_get_posts','tax_and_offset_homepage');
- function homepage_offset_pagination( $found_posts, $query ) {
- $offset = 1;
- if( $query->is_home() && $query->is_main_query() ) {
- $found_posts = $found_posts - $offset;
- }
- return $found_posts;
- }
- add_filter( 'found_posts', 'homepage_offset_pagination', 10, 2 );
- $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
- if( $paged == 1 ) {
- $limit = 10;
- } else {
- $limit = 9;
- }
- 'posts_per_page' => $limit,
Add Comment
Please, Sign In to add comment