WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Impossible? Adding pagination to a loop in custom page. (4 posts)

  1. clouder
    Member
    Posted 7 months ago #

    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.

  2. clouder
    Member
    Posted 7 months ago #

    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(); ?>
  3. clouder
    Member
    Posted 7 months ago #

    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

  4. clouder
    Member
    Posted 7 months ago #

    resolved

Reply

You must log in to post.

About this Topic

Tags

No tags yet.