• Hi there,
    Im trying to add the last sticky post to a section on my homepage as a Featured article. I have no idea of the php code I would need to achieve this and have looked fr an example but nothing seems to work.

    How would I do this?

    Regards,

    Ste

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter nolimit966

    (@nolimit966)

    So far i have this:

    <?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(); ?>

    But the problem is its not STICKY posts that are showing. its just showing a random post.

    Any help would be appreciated.

    Thank you

    Thread Starter nolimit966

    (@nolimit966)

    bump

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Try to avoid using query_posts for something like this. Try using get_post instead.

    Thread Starter nolimit966

    (@nolimit966)

    i tried that, the problem is now that its showing the data from the other loop on the page i.e the ‘latest news’ loop.

    Thread Starter nolimit966

    (@nolimit966)

    fixed it. I was missing the <?php wp_reset_query(); ?> at the bottom of my first loop.

    <?php query_posts(array('post__in'=>get_option('sticky_posts'),'showposts' => 2 )); ?>
    
    	<?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(); ?>

    so the code above worked great.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Feature a sticky on my homepage’ is closed to new replies.