Want to just show just your sticky posts in a WordPress template? This guide tells you how (and much more) – but you’re hacking a theme and are stuck when it says “add this code before the loop” – well the loop is the bit that starts if (have_posts()). In the below example – how to when hackingh the soon-to-be-defunct default Kubric theme.
Add the following
< ?php
// this line just get the sticky posts:
query_posts(array('post__in'=>get_option('sticky_posts')));
// The Loop:
if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>