I coded custom loop within multiple loops structure:
$q = get_posts( $args );
// Run your loop
echo '<div class="row">';
$i = 0;
foreach ( $q as $post ) : setup_postdata( $post );
$i++;
if ($i%4==0)
echo '</div><div class="row">';
get_template_part('loop');
endforeach;
wp_bs_pagination();
wp_reset_postdata();
except for I added wp_bs_pagination();
to load pagination. It only repeat the same set of posts o every page. Any suggestions?
Do not use
get_posts()
for paginated queries.get_posts
works well for non-paginated queries, but not paginated queries.The issue is,
get_posts
only returns the$posts
property fromWP_Query
and not the complete object. Furthermore,get_posts()
passes'no_found_rows'=> true
toWP_Query
which legally breaks pagination.Because
get_posts
usesWP_Query
, we might as well useWP_Query
which returns everything we need to paginate our query. Just remember, we need to add thepaged
parameter to the query in order to page itWe can rewrite your query as follow
You will need to somehow pass
$q->max_num_pages
towp_bs_pagination()
to set pagination to your custom query, but I do not know the function, so I cannot give you an exact solution on this.Try this, paste this in your functions.php
}
and then use the function custom_pagination()
Got the solution from here: http://www.ordinarycoder.com/paginate_links-class-ul-li-bootstrap/