Lets use the classic example of a custom post type called “movies”, with its own taxonomy called “genre”.
By registering the custom post type (with a “movie” slug), the permalinks are already set up for
<domain>/movie/action/
…to see all movies in the action genre.
But, archives by date, like
<domain>/2010/09/
…don’t know about the custom post type.
The closest date-based archive I’m able to get working is:
<domain>/2010/?post_type=movies
…which lists all the custom post types posted during the current year (2010). For some reason, the month, taxonomy and a term cannot be added to the URL to get the expected result.
What must be done to enable url’s like these…
<domain>/2010/09/movie/action/
…to work as expected, thus to list all action movies posted during September 2010?
Yes, there isn’t currently built-in support for CPT archives, but that doesn’t mean you can’t extend WP to provide it. I just did this myself the other day…
This won’t create the date-based archives you’re looking for, but it will give you virtual archive behavior for custom post types. Adding the date should just be a matter of tweaking the rewrite rules (actually, date-based permalinks might just work as-is)…
EXAMPLE: you have a custom type of “movies” and single movie post called “gone with the wind”. This code will give you a URL structure of website.com/movies/gone-with-the-wind. Also, going to website.com/movies will list just the movies (just like a category archive, though it will not call the archive.php template for output, but will format the output just like the standard index.php loop template).
call this function right after having generated your custom post type:
Then, if you would like to be able to use custom templates to control the output of these quasi-archive listings, you can use this:
Now you can create a “movies.php” template in your theme and customize the loop output to your liking..
UPDATE: having the archive functionality for custom types is great, but I realized I needed a way to access them. You can obviously hard-code buttons somewhere that point to the slugs, but I made a function to generate a wp3.0 navbar with all my custom types in it. Right now it spawns a new navbar and makes it the primary, but you could change it to be the secondary, or to just add the items to an existing navbar. Note: the nav links will only work if you’re using the rewrite rules from above.
Custom Post Types are not designed to provide archive as the common blog post post type does. This might be something that will be changed in the future.
This is the missing link: Custom Post Types (CPT) enhancements that deserve consideration in 3.1.
This plugin provides the exactly what you want. It works well with WordPress 3.3.1.