Arguments needed in Wp_Query to hide archived posts?
-
Hello,
My client (for whom I’ve built a theme) has installed this plugin and has noted that one of the loops on the homepage isn’t respecting the new “archive” status — the loop is showing a post which is marked as “archived”.Is there anything I need to do in particular to make this work with your plugin? I have set up the query so that it uses the default for
post_status
, and I would expect this to play nicely with the plugin.Here’s the relevant code, but basically it’s just a call to
new WP_Query([ 'posts_per_page' => 6, 'category_in' => '3,4']);
$args = array(); $args['posts_per_page'] = (int) $attributes['count']; if( ! empty($attributes['categoryid']) ) { $args['category__in'] = array_map('trim', $attributes['categoryid']); } else { $args['category_name'] = $attributes['categoryslug']; } $news = new WP_Query($args); if( $news->have_posts() ) { $out = '<div class="news-posts-with-thumbnails">'; while( $news->have_posts() ) { $news->the_post(); ... } $out .= '</div>'; } ...
And when this loop is returned, it includes the archived post. The post has the status of “archived” and has a date of
08/15/2022
in the Archive Date metabox. The post is not marked as sticky.
- The topic ‘Arguments needed in Wp_Query to hide archived posts?’ is closed to new replies.