show archived posts using WP_Query($args) ?
-
Hi,
Great plugin, thanks!
I’d love to be able to display archived posts of a custom post type by using a WP_Query argument of:
'post_status' => 'archive'
but it doesn’t seem to be working for me. Is it possible?
I only want to show the archived posts of one of many CPTs, and in only one specific place. I don’t want ALL archived posts showing up in all archives.
My code looks like:
<?php $past_args = array( 'post_type' => 'event', 'tax_query' => array( array( 'taxonomy' => 'event-type', //(string) - Taxonomy. 'field' => 'slug', //(string) - Select taxonomy term by ('id' or 'slug') 'terms' => 'training-event' //(int/string/array) - Taxonomy term(s). ), ), 'orderby' => 'menu_order', 'order' => 'ASC', 'post_status' => 'archive', 'posts_per_page' => -1 ); ?> <?php $past_query = new WP_Query($past_args); // Modify the query: ?> <?php /* Start the Loop */ ?> <?php if ( have_posts() ) : ?> <?php while($past_query->have_posts()) : $past_query->the_post(); ?>
If this method isn’t possible, can you suggest another?
Thanks!
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘show archived posts using WP_Query($args) ?’ is closed to new replies.