How do you display the archives of a Custom Post Type by Year & Month?
|
Yes, you can.
All you need is make a filter for
then call this:
Whenever you want to display archive by custom post type, just pass the post_type args:
|
|||||||||
|
|
You don't, the official line from the Wordpress developers was that custom post types weren't intended to do the job of normal ordinary posts, and that if you need post archives of dates etc, then you're not doing things correctly, and you're better off using post formats etc.. Custom post types are intended for web applications etc, whereas doing something such as setting up a custom post type that acts as a secondary or parallel blog with a different name, e.g. blog vs news, with the same abilities, is not what the feature was intended for, and would mean other technical issues arising from its implementation. If you are still insistent on this, and simply using custom taxonomies and post formats is not enough, you could add rewrite rules in functions.php and redirect year/month archives in certain URLs to the post archive page, and then check on the custom post archive page if you've specified variables in your rewrite rules and load a different template, making sure in your rewrite rules to set the appropriate values. |
|||||||||
|
|
Despite claims stating otherwise, you can definitely implement fully functional Year/Month archives for Custom Post Types. It should be part of WordPress, but for now just install "Custom Post Type Archives" plugin - http://wordpress.org/extend/plugins/custom-post-type-archives/. This plugin creates a function called There is one problem with the plugin in that it seems to not work with clean permalinks. So you need to modify the plugin with this fix below or see this reference link. Replace this code in the plugin file "post-type-archives.php" (starting at line 164):
With this code below:
|
||||
|
|
