Display Sticky posts only from specific category
-
I have been working on a personal project to learn more advanced techniques in WordPress and one of the features i require is to display the latest three sticky posts from a specific category. I have some code however its only displaying the latest three posts that not the latest three sticky posts from a specific category.
<?php $sticky=get_option('sticky_posts'); $query_args=array( 'post__in' => $sticky, 'category__in'=>array($category) ); $the_query = new WP_Query($query_args); ?> <?php $count = 0; ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?> <?php $count++; ?> <?php if ($count == 1) : ?> <div class="featurethumb"><?php the_post_thumbnail(array(306,306), array ('class' => 'featurethumb')); ?> <div class="featuretitle-bg"><div class="featuretitle"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></div> <div class="featured-desc"><?php the_excerpt(__('(more…)')); ?></div></div> </div> <?php elseif ($count == 2) : ?> <div class="index-thumb"><?php the_post_thumbnail(array(100,100), array ('class' => 'alignleft1')); ?></div> <div class="indexblog-title"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div> <?php the_excerpt(__('(more…)')); ?> <?php else : ?> <div class="index-thumb"><?php the_post_thumbnail(array(100,100), array ('class' => 'alignleft2')); ?></div> <div class="indexblog-title"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div> <?php the_excerpt(__('(more…)')); ?> <?php endif; ?> <?php endwhile; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Display Sticky posts only from specific category’ is closed to new replies.