admin管理员组文章数量:1313107
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?
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/myposttype/
I want to change that to https://example/xyz/somethingelse/
First I tried to just get it to display https://example/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/somethingelse/, but the page can't be found. Why doesn't it do, what I want?
1 Answer
Reset to default 0have 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.
本文标签: url rewritingHow to change URL for custom post type archive
版权声明:本文标题:url rewriting - How to change URL for custom post type archive? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741932491a2405656.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论