I have a custom post type called “news”. I have a custom block which displays the latest 4 news posts. I’ve installed the Sticky Posts Switch plugin and enabled sticky posts for that CPT. But I’m having a hard time setting up my query args to show any sticky posts first, followed by the latest posts. up to 4 posts in total. Has anybody managed to get this working correctly?
This is my current args.
$args = [
‘post_type’ => ‘news,
‘post_status’ => ‘publish’,
‘posts_per_page’ => 4,
‘order’ => ‘DESC’,
‘orderby’ => ‘date’,
‘no_found_rows’ => true,
];
$sticky = get_option( ‘sticky_posts’ );
$args[‘post__in’] = $sticky;
$query = new WP_Query( $args );