WordPress.org

Support

Support » Themes and Templates » Custom Post Type: Page vs Archive

Custom Post Type: Page vs Archive

  • Here’s what I’m thinking I want to do…
    Create custom post type
    Have a ‘landing’ page that displays all the custom posts.

    I’m getting the hang of custom post types and wondering if I wanted a ‘landing’ page that pulled all of the custom post type entries, should I be making a template using the archive instead of a page?

    I played around with custom page templates and I like how a link to the page automatically shows up in the navigation.

    I’ve also noticed if I make a page and have a custom post type of the same name (same name on the slug) I’ll land on an archive.php template when I click the page’s link in the navigation.

    Is there a best practice approach for using a cpt with a page or is it automatically considered an archive? Or something in Codex I should be reading or re-reading 🙂

    Sorry if I just asked the same question a bunch of different ways.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    @keesiemeijer

    See here what templates you can use for a custom post type archive (if you registered it with 'has_archive' => true, ):

    http://codex.wordpress.org/Template_Hierarchy#Custom_Post_Types_display
    http://codex.wordpress.org/Function_Reference/register_post_type

    I played around with custom page templates and I like how a link to the page automatically shows up in the navigation.

    Depending on your theme you can create a menu under wp-admin > Appearance > Menus
    http://codex.wordpress.org/WordPress_Menu_User_Guide

    I don’t think you can have a page and custom post type with the same slug.

    Thanks very much!! I’m going to take a closer look at those references. The Appearance> Menus seems like something I could use.

    I took a look at changing the ‘has_archive’ => false, which then defaults the page to index.php. An index-{post_type}.php would be interesting and sounds semantically good, but that’s the archive I guess.

    I’m starting to understand the Template_Hierarchy better. I think the custom archive page will work for me as the landing, since I’m looking to pull all the cpts.

    In the end my pages are probably more like parent pages on wireframe to the archive-{post-type}.php pages. Revisiting the naming on those is probably a good thing.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Type: Page vs Archive’ is closed to new replies.
Skip to toolbar