sticky check 2
This commit is contained in:
parent
027df57a2b
commit
aa3d6e0e53
33
sticky.php
33
sticky.php
|
@ -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');
|
$args = array(
|
||||||
// First loop to display only the single, most recent sticky post
|
'posts_per_page' => 1,
|
||||||
$most_recent_sticky_post = new WP_Query(array(
|
'post__in' => $sticky,
|
||||||
// Only sticky posts
|
'ignore_sticky_posts' => 1
|
||||||
'post__in' => $sticky,
|
);
|
||||||
// Treat them as sticky posts
|
$query = new WP_Query( $args );
|
||||||
'ignore_sticky_posts' => 1,
|
if ( isset($sticky[0]) ) {
|
||||||
// Order by ID
|
get_template_part( 'content', get_post_format() );
|
||||||
'orderby' => ID,
|
}
|
||||||
// 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() );
|
|
||||||
?>
|
|
||||||
<?php endwhile; wp_reset_query(); ?>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in New Issue