How do you display a list of archive(last 6 months or so) for custom post types? Something like this: https://blog.evolveformazione.com/

  • What have you tried so far? Maybe check out wphierarchy.com and read over the Template Hierarchy docs
    – Howdy_McGee
    Apr 27 '20 at 18:16
  • On index.php file which displays all blog posts, I'm using <?php the_widget( 'WP_Widget_Archives' ); ?>- which spits out a list of all archive from feb 2019. But the same would not work for custom post types! How do I get around this, please?
    – jeno
    Apr 27 '20 at 18:26
  • The answer is here: wphierarchy.com, you just need to read the article. The WordPress Codex also has the answer here developer.wordpress.org/themes/template-files-section/… which you can copy and paste.
    – Drmzindec
    Apr 28 '20 at 16:22
  • 1
    Many thanks @JohanPretorius. After reading through and some extra googling, the below comment worked for me.
    – jeno
    Apr 29 '20 at 10:54

For anyone still struggling with this, here's a solution:

$args = array(
'post_type'     =>  'your_custom_post_type',
'post_status'     =>  'publish'
$query = new WP_Query($args);


Then output it anywhere in your template like so: //Output <?php wp_get_archives($args); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.