Page/CPT URL conflict
-
I have a custom post type Presse which archive is available at /presse. The archive is only called with taxonomies, e.g. /presse/post_tag/abc, /presse/year/2019, never as the full archive /presse.
I also have a page Presse having the URL /presse as well. It acts as an overview page for the terms of that CPT.
I faced the problem that the CPT archive had overwritten the page address as both have the same URL. Renaming URLs wasn’t an option for me.I found out that there was a rewrite rule
presse/?$ -> index.php?post_type=presse
causing the conflict so I bluntly took it out withadd_filter( 'rewrite_rules_array', 'remove_presse_rewrite_rule' ); function remove_presse_rewrite_rule( $rules ) { foreach ( $rules as $rule => $rewrite ) { if ( preg_match( '/presse\/\?\$/', $rule ) ) { unset( $rules[$rule] ); } } return $rules; }
That solved my problem, however I would like know if this is a proper way of dealing with this kind of issue or if there are cleaner ways?
The page I need help with: [log in to see the link]
- The topic ‘Page/CPT URL conflict’ is closed to new replies.