Turning on permalinks, CPT rewrites are ignored
|Reported by:||andy||Owned by:|
I'm working on rewrite issues in a plugin that registers custom post types. Everything works perfectly if rewrite rules already exist. However, when switching away from the default permalinks (?p=123), no CPT rewrite rules are added. I have to trigger another flush (e.g. by reloading the Permalink Settings page) before the CPT rules appear and my plugin's URLs work.
This bug is due to this check. When switching from no permalink_structure to some permalink_structure, the empty permalink_structure option prevents the rewrite rules and permastructs being added, even though they should be allowed in this case. The result is that the rewrite_rules are generated without any CPT rules.
I suppose the option check is purely for performance reasons. The simplest fix would be to omit the option check which would cause register_post_type to take a little bit longer than necessary on sites without a permalink structure. If this is unacceptable, the fix can ignore the option when is_admin() (or some other test).
Change History (14)
- Keywords has-patch added
- Milestone changed from 3.2.1 to Awaiting Review