0
votes

I have created a couple of custom post types in wordpress, and have set hierarchical to true so it behaves as a page.

The problem is, templates selection isn't available. I've applied this hack to get the menu to appear:

there is a file meta-boxes.php within wp-admin\includes of the wordpress installation.. line 547 of the file, which is the function page_attributes_meta_box() just add the check for your particular post type name to be able to display the template pages drop down.

if ( ('page' == $post->post_type  || 'yourcustomposttype' == $post->post_type) && 0 != count( get_page_templates() ) ) {
        $template = !empty($post->page_template) ? $post->page_template : false;
        ?>

This successfully makes the menu appear, but the data won't save. The "parent" section saves but the "template" doesn't.

Does anyone have any ideas?

3

3 Answers

0
votes
0
votes

Stumbled across this question looking for the same functionality. I know this is a little late but I think I found the solution. By looking into the readme file with the plugin you can add this to your functions.php for the functionality you're looking for.

/**
 * Hooks the WP cpt_post_types filter 
 *
 * @param array $post_types An array of post type names that the templates be used by
 * @return array The array of post type names that the templates be used by
 **/
function my_cpt_post_types( $post_types ) {
    $post_types[] = 'movie';
    $post_types[] = 'actor';
    return $post_types;
}
add_filter( 'cpt_post_types', 'my_cpt_post_types' );
0
votes

This feature is built into core since 4.7. Enable the functionality inside the applicate custom template. For example, if you have a template called "Promotions" and you want to apply it to your CPT "usa, uk, au"

<?php 
  /* 
    Template Name: Promotions
    Template Post Type: page, usa, uk, au
  */

get_header(); ?>

WordPress 4.7 Brings Custom Page Template Functionality to All Post Types