WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Post Templates (7 posts)

  1. MaddTechWF
    Member
    Posted 3 years ago #

    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?

  2. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Will your Portfolio be:

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

  3. MaddTechWF
    Member
    Posted 3 years ago #

    Hey Chip,

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

  4. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    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.

  5. MaddTechWF
    Member
    Posted 3 years ago #

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

  6. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    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.

  7. MaddTechWF
    Member
    Posted 3 years ago #

    Awesome. Thanks Chip. Appreciate the quick help.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.