WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type UI
[resolved] Custom post types as pages with different templates? (3 posts)

  1. micasuh
    Member
    Posted 1 year ago #

    This plugin is great and has served me well for one project. However, now with growing needs from the client, I need to update some capabilities.

    I assume I successfully changed the capability type to be like a page rather than a post:
    http://i.imgur.com/IR8xd.png?1
    (although every time I save, it reverts back to showing as post rather than page)

    The reason I want the CPTs to be like a page is to allow the ability to choose different templates. However, as you can see, it does not give me the option to choose a different template:
    http://i.imgur.com/b9JkJ.png

    What can I do to make the template options show up? I'm at a loss for what I should do next.

    http://wordpress.org/extend/plugins/custom-post-type-ui/

  2. RonStrilaeff
    Member
    Posted 1 year ago #

    This got me curious since I might want to use page templates with a CPT with 'page' capabilities.

    I am seeing a similar thing: my CPT has these args (among others):

    'capability_type' => 'page',
    'hierarchical' => true,
    'supports' => array('title','editor','custom-fields','page-attributes'),

    But the page template dropdown is not showing up in the "Page Attributes" box, in fact the box title is only "Attributes".

    hmmmm ... I just did some code snooping and found this bit of logic in the core file \wp-admin\includes\meta-boxes.php (line 577 of wp-version 3.4.2)

    if ( 'page' == $post->post_type && 0 != count( get_page_templates() ) ) {
    ... show the "Template" dropdown ... }

    That $post->post_type is the name of the database field and the value must be literally 'page' for this to show up. So if I understand this correctly, my 'cpt-page' will never have that Template dropdown!

    I'm starting to think that the custom page templates to show my custom post types need to be of the kind described on these two Codex pages:
    http://codex.wordpress.org/Post_Type_Templates and
    http://codex.wordpress.org/Template_Hierarchy

    Hopefully some guru like the writer of this plugin will dive in to enlighten us. :-)

  3. micasuh
    Member
    Posted 1 year ago #

    After going to the IRC channel for #wordpress, someone found this plugin which seems to do what I want. It's the best solution I could find.

    http://wordpress.org/extend/plugins/custom-post-template/

    In order to make it work for CPTs, you have to enter a custom function into the functions.php file. It lists the instructions on the Other Notes tab.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic