WordPress.org

Ready to get started?Download WordPress

Forums

WP Tiles
[resolved] Pagination (18 posts)

  1. hiphopruckus
    Member
    Posted 1 year ago #

    I think the last thing this plugin needs is Pagination. Is there a way to do that Mike?

    http://wordpress.org/extend/plugins/wp-tiles/

  2. hiphopruckus
    Member
    Posted 1 year ago #

    Anyword on adding pagination to this plugin?

  3. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Hiphopruckus, pagination has not been in the planning for this plugin so far. I'll consider it for the next iteration.

  4. timlim
    Member
    Posted 1 year ago #

    Hi Mike,

    Would love to see pagination on this plugin too. Thanks for the great work!

    cheers,
    tim

  5. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    Hi 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,
    Mike

  6. maciejkurowski
    Member
    Posted 1 year ago #

    Hi 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>

  7. hiphopruckus
    Member
    Posted 1 year ago #

    How do you implement this?

  8. maciejkurowski
    Member
    Posted 1 year ago #

    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>

  9. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks again maciejkurowski, I'll add pagination to a future version of the plugin!

  10. tiaurus
    Member
    Posted 1 year ago #

    Page navigation - the only thing that's missing this plugin.

  11. tiaurus
    Member
    Posted 1 year ago #

    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));
            ?>
  12. tiaurus
    Member
    Posted 1 year ago #

    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; ?>
  13. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    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,
    Mike

  14. tiaurus
    Member
    Posted 1 year ago #

    If 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.

  15. tiaurus
    Member
    Posted 1 year ago #

    Randomly change templates - is that possible?

  16. tiaurus
    Member
    Posted 1 year ago #

    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.

  17. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    Cool, thanks for your feedback. Information about pagination and the template tags is currently found in the FAQ (http://wordpress.org/plugins/wp-tiles/faq/). Is the information here too sparse, or would you expect it somewhere else? Appreciate your comments!

    As for loading a random template - that's a nice idea. Currently, the templates are the only options that are not filterable by plugins or theme code. I'll put it on the road map to include as either an option, or to make this more doable with custom code.
    For now, if you really want to, you could could change the template by outputting javascript that manipulates the wp-tiles-data after the plugin has outputted.. (but this is very hacky)

  18. tiaurus
    Member
    Posted 1 year ago #

    Personally, I have pagination does not work - all the time only shows the first 20 positions. Index.php code is:

    <?php get_header(); ?>
        <div class="tiled-posts-div">
            <?php query_posts("cat=&paged=$paged"); if (have_posts()) :  ?>
                <?php if ( function_exists ( 'the_loop_wp_tiles' ) ) : the_loop_wp_tiles(); endif; ?>
            <?php else : ?>
            <?php endif; ?>
        </div>
    <?php get_footer(); ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.