I would like to have to query loops running on my blog homepage:
- Featured posts on top displaying 3 posts from the category : "Featured"
- Underneath it just the basic loop of wordpress which display the latest (10 or other, whatever is selected within the admin) with "next" and "previous" buttons for archive posts (paged)
Important: The top part will display only 3 posts of the "Featured" category but the regular blog loop underneath will display ALL the posts including the "Featured" ones (even if it's a duplication - the featured posts have to appear also in the regular blog loop)
it seems prety easy but when I tried it couple of times even using rewind_posts
it broke the pagination.
This is the code I originally used:
// Featured posts section
<section class="featured">
<div class="title">
<h4>Featured</h4>
</div>
<?php query_posts('showposts=3&category_name=featured'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article>
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail('post-featured'); ?></a>
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
<p><?php excerpt('20'); ?></p>
<div class="more"><a href="<?php the_permalink() ?>">Continue Reading</a></div>
</article>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
<?php wp_reset_query(); ?>
</section>
// Regular normal posts section
<section class="home-posts">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article class="post-details">
<div class="header">
<h3 class="cat">
<?php
$category = get_the_category();
echo $category[0]->cat_name;
?>
</h3>
</div>
<div class="right-image">
<?php the_post_thumbnail('post-thumb'); ?>
</div>
<div class="title">
<h2><a href="<?php the_permalink() ?>">
<?php the_title(); ?>
</a></h2>
</div>
<div class="date">
<?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>
</div>
<div class="entry">
<p>
<?php excerpt('50'); ?>
...</p>
<?php include(TEMPLATEPATH . '/inc/share.php'); ?>
<a href="<?php the_permalink() ?>" class="more">Continue Reading >></a> </div>
</article>
<?php endwhile; ?>
<?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>
<?php else : ?>
<h2> </h2>
<?php endif; ?>
</section>
hope someone can help Thanks