Within my loop I want to display 9 posts that exclude categories X, Y, Z and all sticky posts.
Between post 3 and 5 I would like to place a sticky post with a custom template.
The below works except that it treats the sticky post as the 4 post from the first loop which results in one regular post missing.
I have to use WP 3.0.3
<?php if (have_posts()) : ?>
<?php $count = 0;?>
<?php
$sticky_posts = get_option('sticky_posts');
$arguments = array(
'posts_per_page' => 9,
'post__not_in' => $sticky_posts,
'category__in' => array(1,2,3,4,5)
);
?>
<?php query_posts( $arguments );?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<?php if ($count == 4) : ?>
<?php
$sticky = get_option('sticky_posts');
$args = array(
'posts_per_page' => 1,
'post__in' => $sticky
);
?>
<?php query_posts( $args );?>
<?php while (have_posts()) : the_post(); ?>
<h1>Latest Sticky Post</h1>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<h1>Regular Post</h1>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php the_excerpt(); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>