WordPress Sticky Post Loop
By default WordPress places the posts that are sticky before any other posts. But what if you want to run a query to show only the sticky’s? perhaps alongside another loop or on a custom page template?
That’s where this nice little loop can help, It outputs the last 15 sticky’s into a 250px box using H5 text.
<!-- start sticky -->
<div style="float:left;width:250px;">
<h4 class="widgettitle">The Sticky Posts</h4>
<?php
$sticky = get_option( 'sticky_posts' ); // Get all sticky posts
rsort( $sticky ); // Sort the stickies, latest first
$sticky = array_slice( $sticky, 0, 15 ); // Number of stickies to show
query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 15 ) ); // The query
if (have_posts() ) { while ( have_posts() ) : the_post(); ?>
<h5 class="smalllist"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h5>
<?php endwhile;?>
<?php } else { echo ""; }?>
</div>
<!-- end sticky -->