WordPress.org

Support

Support » Themes and Templates » [Resolved] Post Templates

[Resolved] Post Templates

  • MaddTechWF
    Member

    @maddtechwf

    Is there a way for me to create two “post” templates that will allow me to have a template for my blog and then one for my portfolio?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Chip Bennett
    Theme Review Admin

    @chipbennett

    Will your Portfolio be:

    1) Part of your blog
    2) A Static Page
    3) A Custom Post Type

    MaddTechWF
    Member

    @maddtechwf

    Hey Chip,

    My portfolio is currently setup to pull based off of a custom post type called “Portfolio”.

    Chip Bennett
    Theme Review Admin

    @chipbennett

    Reference the Template Hierarchy.

    For your “Portfolio” custom post type:

    1) Create a “archive-portfolio.php” as the template file for Portfolio post index (if needed)

    2) Create a “single-portfolio.php” as the template file for the single-post view for Portfolio posts.

    MaddTechWF
    Member

    @maddtechwf

    So how would it know to use the single-portfolio.php page to load my individual portfolio items????

    Chip Bennett
    Theme Review Admin

    @chipbennett

    So how would it know to use the single-portfolio.php page to load my individual portfolio items????

    Because WordPress is awesome like that! 😉

    No, really: the template hierarchy system is setup for this very reason:

    1) Single “Post” Post-type: use single.php
    2) Single “Page” Post-type: use page.php
    3) Single “Custom” Post-type: use single-custom.php

    When you register your Custom Post Type, you assign it a slug, e.g. “portfolio”. WordPress then knows what to do with “portfolio”, and how to apply templates to “Portfolio” Post-types.

    MaddTechWF
    Member

    @maddtechwf

    Awesome. Thanks Chip. Appreciate the quick help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Post Templates’ is closed to new replies.