this is my post loop that i am using
<?php
$sticky = get_option( 'sticky_posts' );
rsort( $sticky );
$args = array(
'post_type' => 'post',
'post__in' => $sticky,
'posts_per_page' => 1
);
$sticky_query = new WP_Query( $args );
while ( $sticky_query->have_posts() ) : $sticky_query->the_post();
?>
<article class="cust-arc-post">
<img src="<?php the_post_thumbnail_url(); ?>" alt="">
<div class="arc-post-header">
<a href="<?php the_permalink(); ?>"><h3><?php the_title(); ?></h3></a>
<a class="cat" href="javascript:;">Category Title</a>
</div>
<p><?php echo wp_trim_words( get_the_content(), 20, '...' ); ?></p>
</article>
<?php endwhile;
wp_reset_postdata();
?>
i tried using offset
but no luck,
i think something is wrong with my loop
if anyone can help me with this
thanks in advance
2
Answers
All the information you need can be found in the theme handbook
As stated in the codex, this displays just the first sticky post, if none return the last post published:
Your problem likely lies in the
rsort();
function, because it’s reversing the array from highest to lowest.Try the below code.