Setting up custom post type archives in WP3.1? Any luck?

I’ve just moved a site I’m developing to WP3.1 so that I can take advantage of and start testing some of the new features. I’m especially liking the has_archive parameter in registering custom post types. I had a post type called ‘recipes’, and added this line to the args on registering it:

'has_archive' => 'recipe-listings',

From what I understand, that should generate the rewrite rules necessary to make /recipe-listings/ be equivalent to /?post_type=recipe. However, I can’t seem to get it working.

Read More

The generic form http://amritafood.com/?post_type=recipe works fine, but http://amritafood.com/recipe-listings/ just goes to 404. What else do I need to do to get custom post type archives working properly? Has anyone else worked it out yet?

Related posts

Leave a Reply

1 comment

  1. I asked the question too soon. And thanks to @Jan Fabry for pointing me in the right direction.

    In case anyone else has this problem, here’s the answer.

    Any time the rewrite rules are changed (adding a new post type, changing the slug or the has_archive slug, etc.) you have to call flush_rewrite_rules once. It has to be called after the post types are registered. I put it at the very end of my function which registered the post types on ‘init’, visited the site once, then deleted it out. Now the site works fine.