Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php $idpost=0; ?>
- <?php global $paged;
- if ( get_query_var('paged') ) {
- $paged = get_query_var('paged');
- } else if ( get_query_var('page') ) {
- $paged = get_query_var('page');
- } else {
- $paged = 1;
- }
- $args = array( 'post_type' => 'post', 'paged' => $paged );
- $q = new WP_Query( $args );
- ?>
- <?php if ($q->have_posts()) : ?>
- <?php while($q->have_posts()) : $q->the_post(); ?>
- <?php if (!is_paged()) { ?>
- <li class="thum_<?php echo $idpost; ?>"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a><br />
- <a class="sname" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
- </li>
- <?php } else { ?>
- <li class="thums_<?php echo $idpost; ?>"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a><br />
- <a class="sname" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
- </li>
- <?php } $idpost++; endwhile; ?>
- </ul>
- <div style="clear:both"></div>
- <?php if ( function_exists('wp_pagenavi') ) { ?>
- <div id="wp-pagenavibox"><?php wp_pagenavi( array('query' => $q) ); ?></div>
- <?php } endif; ?>
- <?php wp_reset_postdata(); ?>
- // in functions I am using
- function custom_posts_per_page($query) {
- if (is_home() && !is_paged()) {
- $query->query_vars['posts_per_page'] = 8;
- return $query;
- } else {
- $query->query_vars['offset'] = 8;
- return $query;
- }
- }
- add_filter('pre_get_posts', 'custom_posts_per_page');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement