How to get post type and month/year before while loop for date.php file

Question

I am trying to create a date.php file for archives for some custom post types. I am using a while loop to get the posts:

<?php while (have_posts()) : the_post(); ?>


I want to customize the date.php file such that it caters to the specific post types that the archive page is for e.g. creating page titles such as “Custom Post Type Name Archives”.

Is there any function where I can get the post type that the archive is referring to BEFORE the while loop? And also for monthly/ yearly archives, is there any way to get the month/date of the posts before the loop begins?

0
2 years 2019-12-28T08:03:18-05:00 0 Answers 93 views 0