If you've set up custom types and given them a custom slug through register_post_type

'rewrite'  => array(
    'slug' => "shoes"

Can you assign a template for /shoes/? At the moment all custom types are just nested inside of a url path that's dead if you navigate to it without the specific item at the end

/shoes/specific_shoe -> custom post

/shoes/ -> index.php

1 Answer 1


Do you have has_archive set to true in you register_post_type function? If so, you can use archive-shoes.php as your archive template.

For more information about registering custom post types, please check https://developer.wordpress.org/reference/functions/register_post_type/


To load a custom archive template (without having to use the default WP template naming conventions), you can use the archive_template hook to set your own.

add_filter( 'archive_template', 'my_shoes_archive_template' );
function my_shoes_archive_template($archive_template) {
     global $post;
     if ( is_post_type_archive ('shoes') ) {
          $archive_template = dirname(__FILE__) . '/my-file-name.php';
     return $archive_template;

Check out https://developer.wordpress.org/reference/hooks/type_template/ for more information on this.

  • Oh yeah, has_archive did the trick! Can you register the archive template programmatically and not through a naming convention somehow?
    – Fluxian
    Aug 1 at 9:53
  • Yes, you can use a hook to set your own template. See updated answer.
    – DeltaG
    Aug 1 at 10:14
  • Thank you that solves all of my problems :)
    – Fluxian
    Aug 1 at 10:16
  • You are very welcome :)
    – DeltaG
    Aug 1 at 10:24

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.