Thursday, September 23, 2010

Wordpress Codex: Return Just The First Sticky Post

First Method
This methode return first sticky post ASC ordered
$sticky=get_option('sticky_posts') ;
query_posts('p=' . $sticky[0]);

Second Method
This method return first sticky post DESC ordered.
If there are not sticky posts, it returns the last post published.
$args = array(
'posts_per_page' => 1,
'post__in' => get_option('sticky_posts'),
'caller_get_posts' => 1
);
query_posts($args);

Source