Custom post type permalinks 404, and flushing the rewrite rules
-
I’m creating a theme with a custom post type, and taxonomy. Permalinks for this, obviously, doesn’t work till the rewrite rules are not flushed, and the rewrite rules – apparently – are not flushing themselves automatically after a new post type or taxonomy has been registered (or removed), so I have to do it myself.
Working permalinks is something that should work right out of the box, so I can not expect of people using this theme to fix this issue for themselves by visit the permalinks.php page. That is just silly.
Solution is adding a $wp_rewrite->flush_rules(); line after all custom post types/taxonomies has been registered. However, that happens on every init, which I don’t think is the right approach (flushing rewrites on each page load).
Is there any pretty solution to this problem?
The best thing possible would be an action hook firing on theme activation, but only after the init hook (after all has been registered). Unfortunately, I was not lucky enough to find anything like that.
- The topic ‘Custom post type permalinks 404, and flushing the rewrite rules’ is closed to new replies.