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.com/file/d/1c1zZsW5xu9bTukEHllsoPS4KyDlfXQS8/view?usp=sharing

  • 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
    Sep 1 '20 at 15:43

I 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.

  • Unfortunately that doesn't seem to be the solution. I tried setting has_archive to false and renaming the rewrite slug, neither of which solved the issue. Maybe there's something I need to flush of the data base after doing that? Then again I would be open to using the archive page instead IF I can figure out how to rename the slug so it shows up as simply "siteurl/comics"
    – ZackAkai
    Sep 1 '20 at 14:47
  • You need to to Settings > Permalinks (just visiting the page is enough) any time you change permalink settings for a post type. Sep 1 '20 at 14:53
  • Thaaaat was it! Funnily enough I had actually already tried renaming the slug before I posted (although I wouldn't have known setting has_archive to true was the root cause of the problem) but gave up on that as a solution until I tried resetting the permalinks just now. Thanks a bunch!
    – ZackAkai
    Sep 1 '20 at 14:58

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.