Support » Plugin: Custom Post Type UI » Page (instead of post) attributes in a CPT?

  • Resolved Pedro Magnifico

    (@pedro-magnifico)


    In the “Attributes” panel, my theme offers a “template” option for pages, but not for posts. For posts the only attribute is “order”. My custom post type only offers my theme’s post attribute option. Can I make my post type offer the template option? I hoped that setting the “capability type” setting to “page” might do the trick, but it didn’t.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    See https://make.wordpress.org/core/2016/11/03/post-type-templates-in-4-7/ for some information on enabling for more than just the “page” post type.

    Thread Starter Pedro Magnifico

    (@pedro-magnifico)

    Maybe Michael’s link had the answer but I didn’t see it. It addresses the question but didn’t spell out how to make the change adequately for me.

    For anyone else who needs a quick answer, check out Custom Post Type Page Template By Hiroaki Miyashita. This worked for my situation.

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    This is the part that you need to use in the custom templates you create:

    <?php
    /*
    Template Name: Full-width layout
    Template Post Type: post, page, product
    */
     
    // … your code here
    

    Specifically the “Template Post Type:” line where you specify what post types it should be made available to. Once you specify your CPTs in that list, a dropdown and the template in question should be made available to use and select.

    Hi,

    Unfortunately, it does not work in CPT. I have the same problem with attributes. I have created a template according to codex instructions. In WordPress Posts this dropdown is shown, but not in CPT Post. Only parent and order. Why? I’m using the default Twenty Seventeen 1.6 theme.

    Regards,
    Artur

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    @3d4u

    Not quite sure what to tell you at the exact moment.

    I created a brand new “movie” post type, set it to hierarchical and set it to have the “page attributes” supports setting. I then created a some-file.php file and pasted the code from my reply at https://wordpress.org/support/topic/page-instead-of-post-attributes-in-a-cpt/#post-10485688 into the top, and it created the dropdown for me to select.

    Screen Shot

    Did you make sure to do the steps I mentioned in my last reply in the thread? Are you sure you saved it to the correct location?

    OK! I did not quite understand how it works. Now I try again.

    Well, the name of the custom post that I created in the CPT must be entered in the Template Post Type line. Now it dawned on me. Everything is correct.

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Glad it was only a small detail that was missed. Hope you have a good rest of your day

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Page (instead of post) attributes in a CPT?’ is closed to new replies.