Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In my theme, I'm using front-page.php for the static front page. I'm also using a page to store the content on the static front page. The front-page.php file is set up to show the content from that page.

However, in the front-page.php file, I also want to show all of my blog's sticky posts below that content. How would I do that?

share|improve this question
add comment

1 Answer 1

Something like this should work:

$sticky = get_option( 'sticky_posts' );
if ( !empty( $sticky ) ) {  // don't show anything if there are no sticky posts
    $args = array(
        'posts_per_page' => -1,  // show all sticky posts
        'post__in'  => $sticky,
        'ignore_sticky_posts' => 1
    );
    $query = new WP_Query( $args );
    if ( $query->have_posts() ) {
        $query->the_post();
        // display your sticky post here (however you like to do it)
    }
}

You should place this in your front-page.php file. It will select all sticky posts and show them.

share|improve this answer
    
Make sure to also add a wp_reset_postdata(); after your if statement to reset the $post global to the main query. –  jjeaton Aug 7 '13 at 15:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.