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?
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.