How to change URL for custom post type archive?


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

I want to change that to

First I tried to just get it to display, 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, but the page can’t be found. Why doesn’t it do, what I want?

TheKidsWantDjent 2 years 2020-12-08T07:10:22-05:00 0 Answers 8 views 0

Leave an answer