WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom Post Type Archive Page 404's and I don't know why? (2 posts)

  1. datdesignguy
    Member
    Posted 3 years ago #

    Hi,

    I'm building an e-commerce store for a client with a "product" custom-post-type. I've created the top-level archive page as indicated in the codex for the post-type and it is stored in my theme folder as "archive-product.php"

    When I visit the url for my custom post-types archive page, which I believe should be: http://site/products, I get a 404.

    Here is the code I'm using to create my custom-post-type:

    http://pastebin.com/NC9ffjKf

    The archive-product.php page doesn't seem to be getting called when I visit http://site/products. Can anyone help me figure this out?

    I have also attached a custom taxonomy of "catalog" as shown here:

    register_taxonomy("catalog", "product", array("hierarchical" => true, "label" => "Catalogs", "singular_label" => "Catalog", "query_var" => true, "rewrite" => true));

    Could this be changing the way wordpress handles my "product" post-type?

    Much appreciated!

  2. datdesignguy
    Member
    Posted 3 years ago #

    Ok, after some more searching here is the simple answer:

    #1 If you want to use a custom archive page for your custom-post-type, add an additional argument to your register_post_type() arguments:
    'has_archive' => true...

    (This will tell WP to look for an archive template according to the codex template hierarchy using the current slug setting of your custom post type. If you want a custom slug for your archives, replace TRUE with the slug name for example: 'has_archive' => 'products' might be the slug you want to use with a 'product' post_type.)

    #2 Visit the Settings -> Permalinks page to flush your current rewrite rules and rebuild with the new rules for your custom archive.

    #3 Visit the url to your custom post type archive

    I found a great tutorial for implementing this here:
    http://mark.mcwilliams.me/2010/10/wordpress-3-1-introduces-custom-post-type-archives/

    Good luck!

Topic Closed

This topic has been closed to new replies.

About this Topic