-2
I need to list the posts on index php. and I want to skip three recent posts. But when browsing the pagination it does not advance the numbers nor change the posts. Or rather, paging doesn’t work when I try to skip these 3 recent posts.
In the functions.php:
function wp_pagination($pages = '', $range = 9)
{
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,
'show_all' => true,
'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 '<div class="wp_pagination">'.paginate_links( $pagination ).'</div>';
}
In the index php.:
<?php global $query_string; parse_str( $query_string, $my_query_array );
$paged = ( isset( $my_query_array['paged'] ) && !empty( $my_query_array['paged'] ) ) ? $my_query_array['paged'] : 1;
query_posts("posts_per_page=10&offset=3paged=$paged"); ?>
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<a href="<?php the_Permalink(); ?>"> <?php the_post_thumbnail(); ?> </a>
<a href="<?php the_Permalink(); ?>"> <h2><?php the_title(); ?></h2> </a>
<?php endwhile; ?>
<p><?php wp_pagination();?></p>
<?php else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
See that I’m using the argument offset=3
to skip these three posts and I’m trying to keep the pagination working but so far without any success.
Jr17, Portuguese, por favor;
– Woss
Excuse me @Andersoncarloswoss I do not know how to use this forum right and also do not like to keep asking questions like these but as I have already searched the solution of this and did not find, and I thought here I could get this help.
– Jr17
@Jr17 Paging works normally without Offset?
– JassRiver
@Heathcliff yes it works normally without offset
– Jr17