WordPress.org

Ready to get started?Download WordPress

Forums

Pagination issue (2 posts)

  1. ThorHammer
    Member
    Posted 3 years ago #

    Hi, in a custom theme I list articles in a specific category, limited to 30 articles per page. But I just can't figure out how to list the next 30 articles (paginated). Here is my code:

    <div class="alignright">
    <!--flow--->
    
    <?php $col = 0; $numcols = 2; ?>
    
    <?php $cool = new WP_Query('cat=5&posts_per_page=30&gdsr_sort=votes&gdsr_multi=0&gdsr_order=desc'); ?>
    <?php while ($cool->have_posts()) : $cool->the_post();
       $post_image = get_post_meta($post->ID, 'image', true);
       $post_alt = get_post_meta($post->ID, 'alt', true);
    ?>
    
    <?php if ($ct && $ct%$numcols==0) echo '<div class="clearcol"></div>'; ?>
    <div class="col">
    <h2><a href="<?php the_permalink() ?>"  rel="bookmark" title="Permanent url to <?php the_title(); ?>"><?php if (strlen($post->post_title) > 20) {
    echo substr(the_title($before = '', $after = '', FALSE), 0, 20) . '...'; } else {
    			the_title();
    			} ?></a></h2>
    <?php if($post_image !== '') { ?>
    <a href="<?php the_permalink(); ?>" title="<?php if($post_alt !== '') echo $post_alt; else the_title(); ?>"><img src="<?php echo $post_image; ?>" alt="<?php if($post_alt !== '') echo $post_alt; else the_title(); ?>" style="width:250px;height:190px; " /></a>
    <?php }
    	else {
    	echo 'missing image';
    	}
    ?>
    </div>
    <?php $ct++; ?>
    
    <?php endwhile; ?>
    <div class="clearcol"></div>
    
    <!-- flow end-->
    </div>

    I would be happy if anyone could assist me. Please.

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    try to add the paged parameter to the query:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    <?php $cool = new WP_Query('cat=5&posts_per_page=30&gdsr_sort=votes&gdsr_multi=0&gdsr_order=desc&paged=' . $paged); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags