WordPress.org

Ready to get started?Download WordPress

Forums

Help with Twenty Twelve, custom post type and templates (6 posts)

  1. critter88
    Member
    Posted 1 year ago #

    Hi,

    I'm following a Lynda.com course on WordPress and custom post types, there is some critical information which appears to be specific to Twenty Eleven, I was hoping for help in doing this in Twenty Twelve.

    I have created a custom post type, and I would like to change the single display page for the post type. The video says to change single.php (but the code is different) and then to create a file called content-<posttype>.php which is the file to make the display changes in.

    I don't know much PHP, but the single.php file in Twenty Twelve seems to already call content-something.php depending on the post type, however I have tried creating a content-posttype.php file and it is ignored.

    If anyone could point me in the right direction or give me a link to some reference material it would be greatly appreciated.

    Thanks!

  2. critter88
    Member
    Posted 1 year ago #

    One further thing, right now I have made a file called single-<posttype>.php and modified the get_template_part call to call the content-<posttype>.php file.

    This seems to work although the get_template_part call in the original single.php must do something similar to this, because the other post types with with the content-<posttype>.php files without adding another single-<posttype>.php

  3. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    to change single.php (but the code is different) and then to create a file called content-<posttype>.php

    One further thing, right now I have made a file called single-<posttype>.php and modified the get_template_part call to call the content-<posttype>.php file.

    should work
    as long as you make sure that your <posttype> does not conflict with the <post_format> used in Twenty Twelve, as the content files are separated by post format; content-{post_format}.php

  4. critter88
    Member
    Posted 1 year ago #

    Thanks for your response alchymyth! :)

    I was getting confused between post formats and types, and I suppose naming the display file content-{post_type} is confusing as it matches the format for post formats, I expect it's better to use a different structure.

  5. eliteclientele
    Member
    Posted 1 year ago #

    critter88,

    I was doing the exact same thing with the tutorial, and ran into this problem. I just had to reset my permalinks.

    Go to settings -> permalinks -> save changes

  6. nztim
    Member
    Posted 1 year ago #

    Thanks eliteclientele, I'll keep that in mind.

Topic Closed

This topic has been closed to new replies.

About this Topic