How to create different post template

Home Forums Support How to create different post template

Home Forums Support How to create different post template

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #165629
    Alessio Angeloro

    Hi Tom,

    i have created a template child with some customization, now i would to create a different post layout for some post, i’have tried with “content-single-%mypostid%.php” but not working; also is it possibile to make this change for the page layout ?

    Thansk so much
    Regards

    #165708
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Hmm, did you find somewhere that told you to use this kind of file name?: content-single-%mypostid%.php

    I can’t find any information on using custom page templates for posts.

    What do you mean by making the change for the page layout?

    Let me know 🙂

    #165715
    Alessio Angeloro

    Hi Tom,

    yes but not with GP, let’s hope the logic it’s the same.

    See this documents https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/

    I need to load some script / php code only in some post or pages.

    Please let me know.

    #165795
    Tom
    Lead Developer
    Lead Developer

    The first point on that page says this:

    Page templates only apply to pages, not to any other content type (like posts and custom post types).

    You can load scripts/PHP code on some posts or pages by using if conditionals: https://codex.wordpress.org/Conditional_Tags

    Specific pages: https://codex.wordpress.org/Conditional_Tags#A_PAGE_Page
    Specific posts: https://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page

    #264384
    Jessica

    I too would love to create different custom layouts for the different blog post formats. I’ve seen it before on other people’s site’s so I’m assuming there’s a way to do it.

    Would I create a custom page called
    – content-single-aside.php
    – content-single-quote.php
    etc.?

    I want to be able to have custom layouts for each of these format types.

    #264438
    Tom
    Lead Developer
    Lead Developer

    I believe it should just be:

    content-aside.php
    content-quote.php

    etc..

    #264751
    Jessica

    Thanks. Worked with a colleague and got it worked out.

    Howevever, these are the only formats I see to choose from:
    standard
    aside
    image
    video
    quote
    link
    status

    Your example (I found in another post) referenced additional types:
    gallery
    audio
    chat

    Is there a way to enable the last 3?

    I’ve since created a custom workaround to have (essentially) custom post types for the blog posts and created custom page templates but wondered but those last 3 weren’t showing up in the format options.

    Thanks!

    #264819
    Tom
    Lead Developer
    Lead Developer
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.