Skip to content

Instantly share code, notes, and snippets.

@mfields
Created July 13, 2011 01:05
Show Gist options
  • Select an option

  • Save mfields/1079539 to your computer and use it in GitHub Desktop.

Select an option

Save mfields/1079539 to your computer and use it in GitHub Desktop.
Sticky Posts
<?php
if ( ! have_posts() ) {
/**
* @todo Some kinda 404 stuff here...
*/
}
/*
* Loop for Sticky Posts.
*/
$stickies = array();
while ( have_posts() ) {
the_post();
if ( ! is_sticky() ) {
continue;
}
$stickies[] = $post;
}
if ( ! empty( $stickies ) ) {
$post = array_pop( $stickies );
setup_postdata( $post );
print "\n" . '<div id="intro">';
the_title( "\n" . '<h1>', '</h1>' );
print "\n" . '<div id="summary">';
the_content();
print "\n" . '</div>';
wp_link_pages( array(
'before' => '<div class="page-link">',
'after' => '</div>'
) );
print "\n" . '</div>';
}
if ( ! empty( $stickies ) ) {
foreach ( $stickies as $i => $stickies ) {
the_title( '<h2>', '</h2>' );
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment