Yes it is possible,
But category page will need 2 post queries for that according to my stupid mind :).
First query will grab first 6 posts via posts_per_page = 6.
Second one will grab posts greater than 7.
For more information look at this http://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination.
Thread Starter
mty42
(@mty42)
Is this not possible then? It must be. Please help WP boffins!
Thread Starter
mty42
(@mty42)
Hi,
Thank you for replying, yes that is what I want, but even with that link I’m not sure how to achieve it. I am not much good with PHP, copy, paste and hope for the best is not working this time…
I need a query that asks:
If a user is on category A then the page grabs the first 6 posts from A then lists the rest (7 – Nth) underneath, stoping after say 20 and paging the rest.
If they land on category B I want the same to happen, so one loop for all categories.
This is my very very poor code:
<h2 class="page-title"><?php single_cat_title(); ?></h2>
// If less than page 2
<?php if ( $paged < 2 ) : ?>
// Show this Carousel
<?php
if (is_category()) {
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
echo $cat_obj->name . " has id ". $cat_obj->term_id;
}
?>
<div class="flexslider">
<ul class="slides">
<?php
$custom_query = new WP_Query(array(
// Somehow get the current category ID... this does not work...
'category' => $cat_obj,
'post_status' => 'publish',
'post_type' => 'post',
'order' => 'ASC',
'orderby' => 'none',
'posts_per_page' => '6',
'offset' => '1',
'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1
));
while ($custom_query->have_posts()) : $my_query->the_post(); $do_not_duplicate[] = $post->ID;
?>
<li class="carousel-article">
<a href="<?php the_permalink() ?>" rel="bookmark">
<article>
<?php the_post_thumbnail(); ?>
<div>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<?php the_category(); ?>
</div>
</article>
</a>
</li>
<?php endwhile;?>
</ul>
</div>
// Then display the rest of the results, this does not work well either
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_post_thumbnail(); ?>
<div>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
</article><!-- #post -->
<?php else : ?>
// on page two and beyond show even more of the results
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_post_thumbnail(); ?>
<div>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
</article><!-- #post -->
<?php endif; ?>