I expected that wp3.1 with the support for archive-{post_type}.php would solve my problems. However, I am still struggling to get it working.
What I want is: a custom date-based archive page per post-type, which displays years and months. Once you click on a year of a month, you’ll go to another archive page which outputs the relevant posts.
First of all: I am clueless on how to create a date-based archive page for certain post-types anyway. Is there a certain page-template which automatically gets called when going to {post-type}/archive? <?php wp_get_archives(); ?>
doesn’t seem post-type aware.
Second of all my date-based permalinks doen’t work. A simple {post-type}/2010/01 gives an error404. I’ve created all my archive-.php pages with simple content:
get_header(); ?>
<section id="content" class="hfeed">
<?php get_template_part('posts'); ?>
</section>
<?php get_footer(); ?>
Any clue?
Did you add
'has_archive => 'my_slug'
to yourregister_post_type()
arguments?That should at least help you with your second problem.
The problem I think you are having is that WordPress doesn’t touch its built in tags such as date and postname when you are using custom post types. Try using this code, which is found here:
This is a filter that is normally built in and called into WordPress when dealing with posts but doesn’t get called for custom post types. Basically, it handles tags that are used with permalinks. This code should let you use dates for your CPT.