Support » Fixing WordPress » Impossible? Adding pagination to a loop in custom page.

  • Resolved clouder

    (@clouder)


    I have been searching for the answer to this to no avail. Hopefully, you guys could point me in the correct direction.

    ?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php get_template_part( ‘content’, ‘page’ ); ?>
    <?php endwhile; else: endif; ?>

    <?php query_posts(‘category_name=’.get_the_title().’&post_status=publish,future’);?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <div class=”cattemptwrapper”>
    <div class=”cattempthumbnail”>“><?php the_post_thumbnail(‘thumbnail’); ?></div>

    <div class=”cattemptitle”><h1>“><?php if (strlen($post->post_title) > 40) {
    echo substr(the_title($before = ”, $after = ”, FALSE), 0, 40) . ‘…’; } else {
    the_title();
    } ?>
    </h1></div>

    <div class=”cattempinfo”>
    <div class=”cauthor”>by <?php the_author_posts_link(); ?></div>

    <div class=”cviews”><?php if (function_exists(‘wpp_get_views’)) { echo wpp_get_views( get_the_ID() ); } ?> views</div>

    <div class=”cdate”> <?php echo human_time_diff( get_the_time(‘U’), current_time(‘timestamp’) ) . ‘ ago’; ?></div></div>
    </div><!–#cattemptwrapper–>

    Any help would be greatly appreciated. I’m running out of ideas on how to enable pagination and my php knowledge is limited. Thank you for taking the time.

Viewing 3 replies - 1 through 3 (of 3 total)
  • An update I changed it to wp_query and it still works, but don’t know how to paginate.

    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php get_template_part( 'content', 'page' ); ?>
    	<?php endwhile; else: endif; ?>
    
    	<?php global $wp_query;
    
    	$wp_query = new WP_Query('category_name='.get_the_title().'&post_status=publish,future');?>
    	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    NVM figured it out.

    I used

    $wp_query = new WP_Query('category_name='.get_the_title().'&post_status=publish,future'.'&showposts=12'.'&paged='.$paged);?>

    to paginate the query and use

    next_posts_link('&laquo; Older Entries', $new_query->max_num_pages) ?>
    
    <?php previous_posts_link('Newer Entries &raquo;') ?>

    to display the navigation links

    resolved

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Impossible? Adding pagination to a loop in custom page.’ is closed to new replies.