• Resolved hommealone

    (@hommealone)


    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!

    https://www.ads-software.com/plugins/archived-post-status/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Frankie Jarrett

    (@fjarrett)

    This code should work, but you may have to change the archive status so it is public. It is private by default. There is a filter to change this explained the FAQ. Let me know how it goes!

    Thread Starter hommealone

    (@hommealone)

    Thank you! My concern with that approach would be that all of our “Archived” content would start showing up all over the site, and not just in this particular loop.

    What do you think?

    Plugin Author Frankie Jarrett

    (@fjarrett)

    Yeah I don’t know off hand, it’s an interesting use-case though. I should have some time later next week to try a few things out.

    Thread Starter hommealone

    (@hommealone)

    Thanks again.

    Don’t knock yourself out on my account. If it has your curiosity peaked, or you think it may be helpful to others, go ahead. But as for me, I’ve worked around it using a different approach altogether, so this isn’t critically important. I’d still be interested in a solution, but it’s not necessary!

    Thanks again for this terrific plugin.

    Hello,

    Really interested in getting this to work for me as well, anyone have a final solution how to set it up ? ??

    Thank you.

    @thesickle: This is not your topic. If you require assistance then, as per the Forum Welcome, please post your own topic.

    Thread Starter hommealone

    (@hommealone)

    FYI, in my case, since I wanted to show archived posts of only one of many Custom Post Types, I just built a new field into the post type editing screen (“Current” or “Archived”) and check for that value when I do the query. Worked for me.

    In another case, I included a “Current until” date field in the CPT, and compare that date to the present date to determine what gets shown where.

    Let me know if you want more details.

    Thanks for the update ?? I am trying to keep modifications to a minimum, started a new thread here, if you can help it would be much appreciated ??
    https://www.ads-software.com/support/topic/how-to-display-archived-posts-on-a-separate-page?replies=2

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘show archived posts using WP_Query($args) ?’ is closed to new replies.