0

I'm trying to change the URL for my custom post type archive.

At the moment, the archive of my post type has the URL https://example.com/myposttype/

I want to change that to https://example.com/xyz/somethingelse/

First I tried to just get it to display https://example.com/somethingelse/, but that doesn't even work. I thought the rewrite parameter would do this when I register the custom post type.

$args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'menu_position' => 6,
    'menu_icon' => 'dashicons-list-view',
    'show_in_rest' => true,
    'rewrite' => array('slug' => 'somethingelse'),
    'supports' => array('title', 'editor', 'thumbnail', 'comments', 'excerpts', 'revisions', 'custom-fields'),
    'show_ui' => true,
    'show_in_menu' => true,
    'query_var' => true,
    'has_archive' => 'myposttype'
);

But the rewrite doesn't seem to do anything. I refreshed the permalinks and went to https://example.com/somethingelse/, but the page can't be found. Why doesn't it do, what I want?

1 Answer 1

0

have you tried going to settings -> Permalinks and choose Numeric and then change that back to whatever, you have it to before and then try again. I remember doing that for one of my projects and that fixed my problem.

1
  • Yes, I have tried that. Didn't help. Commented Dec 8, 2020 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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