Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Pagination with multiple loops WordPress

  • REFUNDED

I've run into a bit of a issue adding pagination to my index.php that calls for multiple loops.
The first loop is a full post followed by 4 post snippets with a thumb & excerpt. I based my layout based off these 2 tutorials:

http://blog.teamtreehouse.com/wordpress-loop-beginners-guide
http://wpquestions.com/question/showChrono/id/3271

I basically just need a link at the bottom of the page stating to view more post then once clicked viewed full posts.

Here is my index php code

<?php query_posts('showposts=1&post_type=post'); ?>

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>



<header class="article-header">

<h1 class="h2 entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
<p class="byline entry-meta vcard">
<?php printf( __( '', 'bonestheme' ).' %1$s %2$s',
/* the time the post was published */
'<time class="updated entry-time" datetime="' . get_the_time('m.d.Y') . '" itemprop="datePublished">' . get_the_time(get_option('date_format')) . '</time>',
/* the author of the post */
'<span class="by">'.__( '| by ', 'bonestheme').'</span> <span class="entry-author author" itemprop="author" itemscope itemptype="http://schema.org/Person">' . get_the_author_link( get_the_author_meta( 'ID' ) ) . '</span>'
); ?>
</p>

</header>



<!-- post body content-->
<section class="entry-content cf">
<?php the_content(); ?>
</section>
<!--end post body content-->

<footer class="article-footer cf">
<p class="category-article-footer">
<?php printf( '<p class="footer-category">' . __('', 'bonestheme' ) . ' %1$s</p>' , get_the_category_list(', ') ); ?>
</p>

<p class="footer-comment-count">
<a href="<?php comments_link(); ?>"><?php comments_number( __( '<span>No</span> Comments', 'bonestheme' ), __( '<span>One</span> Comment', 'bonestheme' ), __( '<span>%</span> Comments', 'bonestheme' ) );?></a> |

<!-- ADDTHIS BEGIN -->
<script type="text/javascript">
var addthis_config = {

}
</script>

<a href="http://www.addthis.com/bookmark.php?v=250"
class="addthis_button">share this post</a>

<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
<!-- ADDTHIS END -->





</p><!-- end footer comment area-->


</footer>



<?php endwhile; else: ?>

<p>Sorry, there are no posts to display</p>

<?php endif; ?>


<hr>


<div class="latest"><h5><span>the latest</span></h5></div>


<?php query_posts('showposts=4&offset=1&post_type=post'); ?>

<?php rewind_posts(); ?>

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<!--start grid posts-->

<div class="gridpost m-all t-all d-1of2" style="float: left;">
<?php

if ( has_post_thumbnail() ) {
the_post_thumbnail( array(315, 315) );
}

?>

<p class="gridtitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<p class="byline entry-meta vcard">

<?php printf( __( '', 'bonestheme' ).' %1$s %2$s',
/* the time the post was published */
'<time class="updated entry-time" datetime="' . get_the_time('m.d.Y') . '" itemprop="datePublished">' . get_the_time(get_option('date_format')) . '</time>',
/* the author of the post */
'<span class="by">'.__( '| by ', 'bonestheme').'</span> <span class="entry-author author" itemprop="author" itemscope itemptype="http://schema.org/Person">' . get_the_author_link( get_the_author_meta( 'ID' ) ) . '</span>'
/* the category */
);
?>

<?php printf( '<span class="footer-category">' . __('', 'bonestheme' ) . '| %1$s</span>' , get_the_category_list(', ') ); ?>

</p>


<span class="excerpt"><?php the_excerpt(); ?></span>



</div>
<!--end grid posts-->



<?php endwhile; else: ?>

<p>Sorry, there are no posts to display</p>

<?php endif; ?>

Answers (1)

2015-09-18

dimadin answers:

<blockquote>I basically just need a link at the bottom of the page stating to view more post then once clicked viewed full posts.</blockquote>

It is now clear to me what that link would do. Right now, you have one post that shows full content, and after that four posts that displays excerpts.

You say that you need a link after that. What would that link do?

Or maybe you want a link below all four posts with excerpts that would point to that post's full page?

If this is the case, you would just need something like this placed after <span class="excerpt"><?php the_excerpt(); ?></span>:

<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">View More</a>


sestrada comments:

I already solved this. Basically I wanted a full post followed by 4 recent post excerpts. I needed a link below all 5 posts to view more posts. Since I was using query_posts with an offset for the 4 additional posts, pagination does not work. I would have to rewrite a wp_query single loop for both posts.

Instead I created a archive page of all posts (minus the first 5 from the home page) and liked the "view more posts" to the archive page.

thanks anyway!