WordPress is wonderful publishing platform, there are so many query that we can tweak it. On this chapter I will show you How to display a sticky post only in our loop. All need to do only written some code below on which area you want, example display it on sidebar.php or in header.php or footer.php. Let’s get started. Open you theme files and added this code
<?php $sticky = get_option( ’sticky_posts’ ); query_posts( array( ‘post__in’ => $sticky, ‘caller_get_posts’ => 1, ‘orderby’ => ID, ’showposts’ => 2 ) ); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h3><a href=”<?php the_permalink(); ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”></h3> <?php the_excerpt(); ?> <?php endwhile;?> <?php endif; ?>
And done, you have create WordPress Loop and only do looping on sticky post only. There are so many solution to How to display a sticky post, like some sample from Justin Tadlock, use you creatifty and enhanced this code above.




Pingback: wp-popular.com » Blog Archive » How To Display a sticky post only # WordPress Tricks & Tips
I’m just new in using word press. I’m still learning every little bit of it. And I don’t get your code here. But I will try it and figure it out. Thank you by the way.
Pingback: The Best way to replace words in your posts | Jhez3R
Great post. I’m a normal visitor of your blog and appreciate you taking the time to maintain the nice site. I’ll be a regular visitor for a long time.