Site icon Hip-Hop Website Design and Development

WordPress Custom Post Type – Post Attribute: Template. Template shows up and saves on the back end, but the default theme file is being rendered

Edit: Now I’ve found that this is Hybrid Core, and apparently the template hierarchy is different. I still haven’t solved my problem below though.

In addition to the title. My thinking is that if I am able to select a template in the backend, it should honor that selection. It doesn’t change though. I’ve tested the other template file in place of the default, and it works.

This is the function to add my custom post type. This works just fine.

add_action( 'init', 'register_cpt_location' );

function register_cpt_location() {

$labels = array(
    'name' => _x( 'Locations', 'info_location' ),
    'singular_name' => _x( 'Location', 'info_location' )
);

$args = array(
    'labels' => $labels,
    'description' => 'Custom Post Type for Location',
    'hierarchical' => true,
    'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'revisions', 'page-attributes' ),
    'public' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'menu_position' => 6,
    'show_in_nav_menus' => true,
    'publicly_queryable' => true,
    'exclude_from_search' => true,
    'has_archive' => true,
    'query_var' => true,
    'can_export' => true,
    'rewrite' => array( 
        'slug' => 'location', 
        'with_front' => false,
        'feeds' => true,
        'pages' => true
    ),
    'menu_icon' => 'dashicons-location',
    'capability_type' => 'post'
);

register_post_type( 'info_location', $args );   
}

When I add a template for the custom post type (only to use on a few posts), the metabox shows up with my new template. However, the live page still uses the default template for the custom post type.

The default template is “info_location.php”.

This is my head info for the template file “info_location-fm.php”.

/*
* Template Name: Location-fm
* Template Post Type: info_location
*/

showing the drop down for templates (below)

new template selected and saved, still doesn’t work (below)