Or, you can do that – after headhache and spent one day to find a solution :
You have to set ‘rewrite’ => false in your register_post_type();
and add after closing register_post_type() :
// 404 CPT permalink WP bug...
global $wp_rewrite;
$projet_structure="/projets/%projet%";
$wp_rewrite->add_rewrite_tag("%projet%", '([^/]+)', "projet=");
$wp_rewrite->add_permastruct('projet', $projet_structure, false);
Where projet is my CPT
See here for more.
Enjoy !
Related Posts:
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- Best way to flush_rewrite_rules for custom post type, in a mu-plugins plugin?
- Remove Slug from Custom Post Type results in 404
- On clicking on the category name the page is redirecting on 404 pge
- Remove POST_TYPE from custom post type permalink
- Customize permalink when creating a post
- Custom Permalink to remove category word , keeping posts permalink with date?
- Custom Endpoint For Specific Custom Post Type
- Error 404 change permalink term custom term taxonomy
- Changing CPT permalink
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- % encoded URL giving 404 error in WordPress
- Can I override the permalink/slug on creation
- Add category slug as class attribute in a link array
- Bizarre Permalinks Issue: 404 Errors Everywhere
- Easy way to change custom post type name for permalinks?
- Custom post type permalinks
- Use different taxonomies in different custom post types’ permalinks?
- custom permalinks based on taxonomies for custom post type
- Why does wordpress keep adding postname to my CPT’s permalink in the end?
- Hook to override title, image and content
- Insert Multiple Post with Same Publish Button
- post_type_link not working in gutenberg
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- Wrong generated page_name/slug on first publish of custom post type
- Remove post type slug of all post types from permalinks
- Custom template won’t load for a custom post type (custom permalinks used)
- Making a custom help center page
- Stop / prevent WordPress from updating permalinks of custom post type
- Custom taxonomy in URL showing 404
- get_object_taxonomies() returns empty array for custom post type
- Custom post type and permalink issue
- How do I correct an incorrect permalink?
- How can I update the permalink everywhere for a custom post type?
- Update permalinks when new category added to custom post type taxonomy
- WordPress theme custom capabilities not works
- custom post type not showing in menu
- Custom posts don’t work
- Add archive slug to default post post type
- Custom Post type and permalink settings
- No posts found – Custom Post Type show_ui
- Custom rewrite rule for hierarchical custom post type
- How to customize a permalink (URL) structure?
- Adding a custom post type taxonomy template in plugin
- Plugin: register custom post types, child ready and performance best practices
- How to add a custom taxonomy to show up in a custom post type menu?
- Tag Archive for Custom-Post-Type Posts yielding 404 when permalinks set to postname
- add category name to permalinks on product page /category-name/product-name
- Use menus with anchors
- Custom Post Type permalink shows wrong page: homepage/index.php
- Get term name and term parent into custom post type permalink
- WordPress add_permastruct unwanted matches
- Rewrite rules for custom posts types
- Permalink structure by Post Meta value
- Give a permalink to Custom Post Types without title
- Does WordPress consider a post name unique if that same post name is in multiple Post Types?
- Why doesn’t a custom post type permalink ever hit index.php
- How to hook custom taxonomies to custom post types and make the permalinks work?
- custom post type parsed as attachment
- Getting template_include to work when allow_url_include is off?
- 404 Issue w/ Custom Post Type – using Meta for Permalink rewrite
- WordPress Custom Post Type Repeated 404 Errors
- Child post with numeric only slug keeps redirecting to parent
- WordPress post_where & posts_join not working only for custom post type
- How to change custom post type permalink structure
- Custom post type url with category
- Add custom ID to CPT posts only create not update
- Help with Elementor Pagination CPT archive 404 problem
- Add custom post type as submenu [closed]
- WordPress multiple custom post types capability conflict in a single menu
- Adding custom post category slug in permalink causes 404 error for pages and posts
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- Allow post/page hierarchy across different post types?
- Getting meta in editor plugin, and event triggering issue
- Permalink for a custom post type isn’t working and I don’t know why
- Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together
- Orderby CPT custom fields not working
- Add custom post type settings to wordress default posts
- How Can I Change the Custom Post Type Slug to the Taxonomy Slug in the URL?
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- WordPress Custom Post Type Permalinks dynamic term slugs
- Unable to get Custom Plugin Options data
- How to have the same url structure for both a CPT and a Taxonomy?
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- create a subcatagory for a custom post type and out put url as posttype/subcategory/item
- Update post meta not working in transition_post_status
- How can achieve this permalink perfectly? domain.com/%category%/%post-name%
- custom-taxonomy/post_name instead of the default post_type/post_name
- Use custom metabox to update automatically a post after a given date
- Show custom post archive when custom post not specified
- Show custom post type relationships by taxonomy
- Assign same parrent Page to pages AND custom post types
- Can’t remove front from permalinks for custom taxonomy category page
- WordPress custom post type permalink rewrite shows page not found
- How to set a CPT to have a page as a parent, then rewrite urls accordingly?
- Completely remove custom post type permalinks (“One Page” website)
- Using taxonomy term in CPT permalink – Pages 404’s
- Addition of custom option panel crashes Media Library & Admin Area
- Removing custom post type slug from URL
- How to add rewrite rule to custom post type with parent in url with cpt ui?