sticky check 2

This commit is contained in:
Holger Könemann 2015-08-12 13:06:37 +02:00
parent 027df57a2b
commit aa3d6e0e53
1 changed files with 11 additions and 22 deletions

View File

@ -3,29 +3,18 @@
<div class="container"> <div class="container">
<div class="col-md-12"> <div class="col-md-12">
<?php <?php
// Get IDs of sticky posts
$sticky = get_option( 'sticky_posts' ); $sticky = get_option( 'sticky_posts' );
// First loop to display only the single, most recent sticky post $args = array(
$most_recent_sticky_post = new WP_Query(array( 'posts_per_page' => 1,
// Only sticky posts
'post__in' => $sticky, 'post__in' => $sticky,
// Treat them as sticky posts 'ignore_sticky_posts' => 1
'ignore_sticky_posts' => 1, );
// Order by ID $query = new WP_Query( $args );
'orderby' => ID, if ( isset($sticky[0]) ) {
// Get only the most recent
'posts_per_page' => 1
));
while ($most_recent_sticky_post->have_posts()) : $most_recent_sticky_post->the_post(); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', get_post_format() ); get_template_part( 'content', get_post_format() );
}
?> ?>
<?php endwhile; wp_reset_query(); ?>
</div> </div>
</div> </div>
</div> </div>