Im trying to add the last sticky post to a section on my homepage as a Featured article. I have created this so far and it displays posts but not the sticky ones:

<?php query_posts(array('post__in'=>get_option('sticky_posts'),'showposts' => 1 )); ?>
<?php while (have_posts()) : the_post(); ?>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_content(''); ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>

I have tried to change the query_posts to get_post. The problem then is that it displays the other 3 'latest news' posts from the other loop at the top of the page.

Any help would be really really appreciated

  • The normal loop for getting posts should automatically put sticky posts at the top?
    – Dave Burns
    Aug 9 '13 at 10:46

Try this. It should work

$args = array(
    'post__in' => get_option('sticky_posts'),
    'showposts' => 1,
    'orderby' => date, 
    'order' => 'desc'

$sticky = new WP_Query( $args );
if ( $sticky->have_posts() ):
    while ( $sticky->have_posts() ): $sticky->the_post();
        echo the_title();

  • @ste, nice to hear it. You can accept the answer so the question will be marked as anwered. Aug 9 '13 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.