admin管理员组文章数量:1323317
I'm trying to create a page called "Comics" with the slug "comics" to use as the main table of contents for my webcomic site. I've created a page-comics.php file, however when I go to the page it just links back to index.php. It also doesn't work when I try using the ID instead. When I try using this same format with other slugs and IDs it works fine, so I know WordPress is working correctly. I thought it might be conflicting with something I had in functions.php, however nothing else was using the name "comics" (I've linked to the file below for anyone to view). I also tried scrubbing the database for any deleted items that might have been using that slug and got nothing. Does anyone know what could be causing this issue?
My functions.php file:
I'm trying to create a page called "Comics" with the slug "comics" to use as the main table of contents for my webcomic site. I've created a page-comics.php file, however when I go to the page it just links back to index.php. It also doesn't work when I try using the ID instead. When I try using this same format with other slugs and IDs it works fine, so I know WordPress is working correctly. I thought it might be conflicting with something I had in functions.php, however nothing else was using the name "comics" (I've linked to the file below for anyone to view). I also tried scrubbing the database for any deleted items that might have been using that slug and got nothing. Does anyone know what could be causing this issue?
My functions.php file: https://drive.google/file/d/1c1zZsW5xu9bTukEHllsoPS4KyDlfXQS8/view?usp=sharing
Share Improve this question asked Sep 1, 2020 at 14:31 ZackAkaiZackAkai 434 bronze badges 1- 1 Can you include your code in your question? Links offsite break and this question makes no sense without the google drive link – Tom J Nowell ♦ Commented Sep 1, 2020 at 15:43
1 Answer
Reset to default 1I thought it might be conflicting with something I had in functions.php, however nothing else was using the name "comics"
There is, here:
// Arguments
$args = array(
'labels' => $labels,
'public' => true,
'menu_icon' => 'dashicons-book-alt',
'hierarchical' => true,
'exclude_from_search' => false,
'has_archive' => true,
'publicly_queryable' => true,
'rewrite' => array( 'slug' => 'comics', 'with_front' => false ), // <-- Here
'supports' => array( 'title', 'page-attributes' ),
);
// Register Comic Pages Post Type
register_post_type('comic-page', $args);
So you have a post type with the slug comics
, which has has_archive
set to true
, meaning that the URL /comics
is being used to display the archive of the comic-page
post type. If you want to customise the template for this archive you should create an archive-comic-page.php
file, as per the template hierarchy.
If for some reason you don't want this archive, you can set has_archive
to false
to disable it, freeing you up to use /comics
for a page.
本文标签: pageslugphp not working but only for specific slug
版权声明:本文标题:page-slug.php not working but only for specific slug 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742144110a2422712.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论