0

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.

0

flush your permalinks. Go to settings / permalinks and hit save.

  • Nope, unfortunately that didn't help. The page is: reflectivedata.com/analytics-dictionary – Silver Ringvee Apr 17 '17 at 19:59
  • that's not /dictionary as a page. I tried going to /dictionary and it takes me back to that page though. does the site load as normal without 404 when you disable cpt ui? – rudtek Apr 17 '17 at 20:04
  • yeah, sorry, on real site dictionary is actually analytics-dictionary (just shortened it in the question). But disabling cpt ui didn't change anything. – Silver Ringvee Apr 17 '17 at 20:45
0

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.

  • That's not what with_front does, it controls whether any prefix on the built in post type gets added to cpt urls. – Milo Apr 17 '17 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.