So my issue is this. I’m building a news site that needs to display several lists of links on the homepage for the current date.
I’ve separated the different sections into custom post types for ease of admin management.
This works fine when you visit the homepage as I’m querying each post type for the current date.
Now my problem is I want to use the native query vars for year, month and day and display a page set up similar to the homepage but that displays all the different post types from the date set in the url. eg:
I asked the question here already regarding retrieving query vars from the homepage
And was pointed in the direction to use the date.php template.
At first I thought this was fixed and everything was now working well, no redirects, rewrites or extra query vars needed.
The catch is the date.php template is only picked up if I have a regular post published with that date, if not it doesn’t register my custom posts and sends me to the 404 page.
Does anyone have any idea on how to sort this out so that it’ll know to redirect to the date.php as long as one of my custom post types was published on the date specified in the url? That’s all I need. I can handle all the rest as long as I can get it directed to that page.
I’ve tried several different filters etc to try and include custom_post types to the archives and I’m always sure to visit the permalinks page after any changes but I just can’t seem to get any of my post types’ dates to be acknowledged and send me to the date.php.
I also tried setting up the archive-custom_post_type_name.php template but it isn’t re-directing either. (I think because I’m trying to avoid having the additional slug)
Date archives default to querying just the
post
post type, you can add additional post types to those queries via thepre_get_posts
action