Pagination
-
I think the last thing this plugin needs is Pagination. Is there a way to do that Mike?
-
Anyword on adding pagination to this plugin?
Hi Hiphopruckus, pagination has not been in the planning for this plugin so far. I’ll consider it for the next iteration.
Hi Mike,
Would love to see pagination on this plugin too. Thanks for the great work!
cheers,
timHi Tim, thanks for your comment 🙂 I’m putting pagination high on the roadmap for WP Tiles, and will try to include it in version 0.4 when I get around to it.
Cheers,
MikeHi Tim. If you are not very affraid of simple php you can achieve pagination with the current version.
“offset” attribute works fine, it can be passed as a query parameter.
The code below will display 10 posts starting from the offset passed in url:
$postsperpage = 10;
$offset = $_GET[‘offset’]; // get offset from url
$query = ‘numberposts=’. $postsperpage . ‘&offset=’ . $offset;if ( function_exists ( ‘the_wp_tiles’ ) )
the_wp_tiles(array(‘posts_query’=>$query));then you have to add links/divs to next/prev page putting offset +10, -10 respectivelly
eg like this:
$nextpageurl=”http://mygreatepage.com/?offset=” . ($offset+10);
?offset=” . ($offset+$postsperpage);
<a href="<?php echo $nextpageurl ?>">next page</a>How do you implement this?
check out how it works on my blog
the idea is that the offset is in url
eg offset=17 will show posts 17, 18 ..at page generation you have to read this value and forward to tiles query. in my page I updated front-page.php with:
<div id="content" role="main"> <?php $numposts = 17; $offset = $_GET['offset']; $query = 'numberposts='. $numposts . '&offset=' . $offset; $acturl = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'] . "?offset="; if ( function_exists ( 'the_wp_tiles' ) ) the_wp_tiles(array('posts_query'=>$query)); ?> </div><!-- #content -->then you have to create links/divs to pres/next page.
eg like this:<a href="<?php echo $acturl . ($offset + $numposts); ?>">next page</a><br>Thanks again maciejkurowski, I’ll add pagination to a future version of the plugin!
Page navigation – the only thing that’s missing this plugin.
My pagination idea:
<?php $page_num = get_query_var('paged'); $numposts = 20; $offset_plus = $page_num-1; $offset = $offset_plus*$numposts; $query = 'offset=' . $offset; if ( function_exists ( 'the_wp_tiles' ) ) the_wp_tiles(array('posts_query'=>$query)); ?>The correct code:
<?php $page_num = get_query_var('paged'); ?> <?php if ($page_num == 0) : ?> <?php $numposts = 20; $query = 'numberposts='. $numposts; if ( function_exists ( 'the_wp_tiles' ) ) the_wp_tiles(array('posts_query'=>$query)); wp_reset_query(); ?> <?php else : ?> <?php $numposts = 20; $offset_plus = $page_num-1; $offset = $offset_plus*$numposts; $query = 'offset=' . $offset; if ( function_exists ( 'the_wp_tiles' ) ) the_wp_tiles(array('posts_query'=>$query)); wp_reset_query(); ?> <?php endif; ?>Hi Tiaurus, thanks for your comments! If I may ask, why not use
the_loop_wp_tiles()? This template tag was specifically added to make sure that WP Tiles uses the same pagination as the normal WP loop.For example, you could do:
if ( have_posts() ) : if ( function_exists ( 'the_loop_wp_tiles' ) ) : the_loop_wp_tiles(); endif; endif;The main advantage is that this function uses posts per page and the paged query var, so you can let WordPress keep track of the offset.
Cheers,
MikeIf I may ask, why not use the_loop_wp_tiles()?
Because the documentation on the use of plug-in is not provided with examples and detailed description of options. Thanks for the tip, now I will change the code templates.
Randomly change templates – is that possible?
Generally, of course, the plugin is great. Based on it, you can create a variety of themes, templates. Thank you!
Sorry for my bad English.
The topic ‘Pagination’ is closed to new replies.