404 error with custom rewrite to replace underscores
-
Hi there
When I set up the custom post type “news and events”, I mistakenly added what I intended to be the custom rewrite ‘news-and-events’ (to replace underscores with hyphens) to the custom archive URL field instead of the custom rewrite slug.
Now, when I try to fix this, I get a 404 error on any of the news and events single pages. I am stuck with an archive page which uses hyphens (news-and-events) while every single post has underscores.
I have tried removing the custom archive URL text so it’s blank and putting ‘news-and-events’ in the custom rewrite slug field. I have tried resetting permalinks. I have tried various settings combinations but I just cannot crack it.
Really grateful for any help.
Here are my settings:
Public
True
(Custom Post Type UI default: true) Whether or not posts of this type should be shown in the admin UI and is publicly queryable.Publicly Queryable
True
(default: true) Whether or not queries can be performed on the front end as part of parse_request()Show UI
True
(default: true) Whether or not to generate a default UI for managing this post type.Show in Nav Menus
True
(Custom Post Type UI default: true) Whether or not this post type is available for selection in navigation menus.Delete with user
False
(CPTUI default: false) Whether to delete posts of this type when deleting a user.Show in REST API
True
(Custom Post Type UI default: true) Whether or not to show this post type data in the WP REST API.REST API base slug
Slug to use in REST API URLs.
Slug to use in REST API URLs.
REST API controller class
(default: WP_REST_Posts_Controller) Custom controller to use instead of WP_REST_Posts_Controller.
(default: WP_REST_Posts_Controller) Custom controller to use instead of WP_REST_Posts_Controller.
Has Archive
If left blank, the archive slug will default to the post type slug.True
(default: false) Whether or not the post type will have a post type archive URL.news-and-events
Slug to be used for archive URL.
Exclude From Search
False
(default: false) Whether or not to exclude posts with this post type from front end search results.Capability Type
postThe post type to use for checking read, edit, and delete capabilities. A comma-separated second value can be used for plural version.
Hierarchical
False
(default: false) Whether or not the post type can have parent-child relationships.Rewrite
True
(default: true) Whether or not WordPress should use rewrites for this post type.Custom Rewrite Slug
(default: post type slug)
(default: post type slug)
Custom post type slug to use instead of the default.With Front
True
(default: true) Should the permalink structure be prepended with the front base. (example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/).Query Var
True
(default: true) Sets the query_var key for this post type.Custom Query Var Slug
(default: post type slug) Query var needs to be true to use.
(default: post type slug) Query var needs to be true to use.
Custom query var slug to use instead of the default.The page I need help with: [log in to see the link]
- The topic ‘404 error with custom rewrite to replace underscores’ is closed to new replies.