WordPress Custom Post Type Permalinks Broken

I was having a big problem with wordpress’ custom post types (register_post_type) and 404 / not found errors when using custom permalinks (taxonomies). It was quite annoying until I found the problem: it seemed the taxonomy cache needs to be flushed out after you add a new post type. Here are notes on how to fix this problem:

“Been having this issue with custom post types in general. I seem to have a fix that I’m hoping will work for you guys. It’s a two parter.

After you’ve made your changes to functions.php or wherever you’re adding/editing post types or taxonomies,

1) go into the wp_options table in your database and clear out the option_value field for option_name rewrite_rules .

2) Then go back into your WordPress admin > Settings > Permalkinks and click the save button.

This should reset your rewrite rules to reflect your new rewrite settings for your taxonomy.”

“If you are writing a plug-in, add:

add_action('admin_init', 'flush_rewrite_rules');

your rewrite rules will be flushed when you activate the plug-in then.”

^ PS: Don’t leave that enabled b/c it has quite a profound effect on the number of queries needed to load a page each time.

Thanks @stunnaboi and @tombrinkĀ via wp

Final note: If your permalinks are still having issues after trying this, disable the plugins you have running, try this again, and see if that works. If so, one of your plugins is causing trouble with your rewrite rules!

Related Posts:

  • No Related Posts
This entry was posted in Tech Tips, Web Development and tagged . Bookmark the permalink.

7 Responses to WordPress Custom Post Type Permalinks Broken

  1. Pingback: links for 2011-05-08 | Ronaldo Richieri

Leave a Reply

Your email address will not be published. Required fields are marked *