I have a custom page type dictionary
and all of the dictionary items have URLs like this: example/dictionary/item
dictionary has has_archive => false
The problem occurs if I also create a page called Dictionary with an URL example/dictionary
Now, all of the dictionary item pages are giving me an 404 error.
CPT was created using CPT UI
So, my question is: how to make it so that example/dictionary
would show a page called "Dictionary" (not an archive) and that all of the items would show on their URLs, example: example/dictionary/item-1
and not show a 404 error instead.
I refreshed permalinks by going settings -> permalinks, and hitting save.
I have a custom page type dictionary
and all of the dictionary items have URLs like this: example.com/dictionary/item
dictionary has has_archive => false
The problem occurs if I also create a page called Dictionary with an URL example.com/dictionary
Now, all of the dictionary item pages are giving me an 404 error.
CPT was created using CPT UI
So, my question is: how to make it so that example.com/dictionary
would show a page called "Dictionary" (not an archive) and that all of the items would show on their URLs, example: example.com/dictionary/item-1
and not show a 404 error instead.
I refreshed permalinks by going settings -> permalinks, and hitting save.
flush your permalinks. Go to settings / permalinks and hit save.
There is one more thing is possible. When you register the custom post type, you can use additional rewrite
with_front
argument:
$args = array(
// ( ... your arguments here ... )
'rewrite' => array(
'slug' => 'dictionary',
'with_front' => false // notice here
),
// ( ... more arguments here ... )
This will remove the CPT base (dictionary
in your case) from the URL.
And don't forget to flush permalinks each time you change the code relative to them.
See rewrite
in the Codex.