WordPress.org

Forums

[resolved] Pagination for a custom page template (3 posts)

  1. MrThunder
    Member
    Posted 2 years ago #

    Hi I am creating a custom page template and I need to insert pagination. I have tried but i cannot get it to work. How do I do this?

    Thanks for the help.

    <?php get_header(); ?>
    <div  class="modus-grid">
         <?php query_posts( 'post_type=albums&posts_per_page=9'); ?>
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                        <?php $currentid = get_the_id(); ?>
                        <div class="grid-box grid-block mod-box width33">
                            <div class="view view-third">
                                    <?php if (get_the_post_thumbnail($currentid, array(167, 167)) != "") { ?>
                                       <a href="<?php the_permalink(); ?>" /><?php echo get_the_post_thumbnail($currentid, array(300,600)); ?></a>
                                    <?php } else { ?>
                                        <a href="<?php the_permalink(); ?>" /><img src='<?php bloginfo('template_url') ?>/images/default.png' alt='Default'/></a>
                                    <?php } ?>
                        		<div class="mask">
                        			<h2><a href="<?php the_permalink(); ?>"><?php echo get_the_title($currentid); ?></a></h2>
                         			<a href="<?php the_permalink(); ?>" class="info">More  ยป</a>
                         		</div>
                            </div>
                        </div>
                        <?php
                    endwhile;
                endif;
                wp_reset_query();
                ?>
                <div class="clearfix">
    </div>
    <?php get_footer(); ?>
  2. keesiemeijer
    moderator
    Posted 2 years ago #

    Try it with one of these pagination functions after the endwhile; (end of loop):
    http://codex.wordpress.org/Pagination
    example:

    <?php endwhile; ?>
    <div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div>
    <div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div>
    <?php
    endif;
    wp_reset_query();
    ?>

    And try to add the paged parameter to the query:
    http://codex.wordpress.org/Pagination#Adding_the_.22paged.22_parameter_to_a_query

  3. MrThunder
    Member
    Posted 2 years ago #

    That worked perfectly, thanks for your help!!

Topic Closed

This topic has been closed to new replies.

About this Topic