I've got an archive that's displayed using a URL on the form
www.mysite.ex/mycpt and I need to make a rewrite rule for that URL which redirects to a permalink with the latest date archive, which is on the form
www.mysite.ex/mycpt/2012/01/31. The archives use the same archive-mycpt.php template, but my guess is that the fact that it is a Custom Post Type does not matter in this case.
I can get the most recent post date by using get_posts and extract the
post_date for the
post_type and use that info to attach a path to the above mentioned URL. I suppose I could put that in a rewrite rule, but how do I make a rewrite rule that always has up-to-date information on the most recent post date?
I think that I might need to make an action hook somewhere to update the rewrite rule when a new post of the
post_type is made, but I'm not sure which hook to use and how to use it, or if it's a good approach to begin with.
edit: Thanks to woony for pointing me in the right direction.