I set the Block 3 component in home page as infinite scroll. Infinite scroll works but same posts are repeated in every new loading:
http://dl.dropbox.com/u/103580364/temp/000779.jpg
The web site is here:
All plugins are deactivated.
Could you please check this problem? I send the access credentials to contact@tagdiv.com
Hi Marius,
The problem is caused by offset attribute in WP_Query as described here:
offset (int) – number of post to displace or pass over. Warning: Setting the offset parameter overrides/ignores the paged parameter and breaks pagination (Click here for a workaround).
A workaround is described here.
I try to implement that solution. Any help will be appreciated.
The pagination issue is caused by offset parameter. I set offset argument to 5 in order not to repeat the posts in the slider. But this causes the “paged” attribute in WP_Query to be ignored. This is documented in WP Codex:
offset (int) – number of post to displace or pass over.
Warning: Setting the offset parameter overrides/ignores the paged parameter and breaks pagination (Click here for a workaround).
Making Custom Queries Using Offset And Pagination
http://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination
I adopted the solution above to my situation as here:
Newspaper-child\functions.php
add_action('pre_get_posts', 'myprefix_query_offset', 1 );
function myprefix_query_offset(&$query) {
//Before anything else, make sure this is the right query...
$not_in_ajax_call = get_permalink();
$in_home_page = ! is_page('');
if ( $not_in_ajax_call && $in_home_page ) {
return;
}
if ( empty( $query->query['offset'] ) ) {
return;
}
$offset = $query->query['offset'];
//Next, determine how many posts per page you want (we'll use WordPress's settings)
$ppp = get_option('posts_per_page');
//Next, detect and handle pagination...
if ( $query->is_paged ) {
//Manually determine page query offset (offset + current page (minus one) x posts per page)
$page_offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );
//Apply adjust page offset
$query->set('offset', $page_offset );
}
else {
//This is the first page. Just use the offset...
$query->set('offset',$offset);
}
}
-
This reply was modified 12 years by
mertnuhoglu.
