WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a Custom Post Type, and here's the entire code:

// Register Custom Post Type
function wrestler_register() {

    $labels = array(
        'name'                => _x( 'Wrestlers', 'Post Type General Name', 'text_domain' ),
        'singular_name'       => _x( 'Wrestler', 'Post Type Singular Name', 'text_domain' ),
        'menu_name'           => __( 'Wrestler Profiles', 'text_domain' ),
        'parent_item_colon'   => __( 'Parent Item:', 'text_domain' ),
        'all_items'           => __( 'All Items', 'text_domain' ),
        'view_item'           => __( 'View Item', 'text_domain' ),
        'add_new_item'        => __( 'Add New Profile', 'text_domain' ),
        'add_new'             => __( 'Add New', 'text_domain' ),
        'edit_item'           => __( 'Edit Item', 'text_domain' ),
        'update_item'         => __( 'Update Item', 'text_domain' ),
        'search_items'        => __( 'Search Item', 'text_domain' ),
        'not_found'           => __( 'Not found', 'text_domain' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'text_domain' ),
    $rewrite = array(
        'slug'                => 'wrestler',
        'with_front'          => true,
        'pages'               => false,
        'feeds'               => false,
    $args = array(
        'label'               => __( 'wrestler_profiles', 'text_domain' ),
        'description'         => __( 'Profiles of WWE Superstars & Divas', 'text_domain' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'thumbnail', 'custom-fields', ),
        'hierarchical'        => true,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'menu_icon'           => url + '/icon.png',
        'can_export'          => true,
        'has_archive'         => false,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'rewrite'             => $rewrite,
        'query_var'           => 'wrestler',
        'capability_type'     => 'page',
    register_post_type( 'wrestler_profiles', $args );


// Hook into the 'init' action
add_action( 'init', 'wrestler_register', 0 );

Now, I have also added single-wrestler.php to my theme's root, but every time I'm viewing the page it lands on "Single.php".


share|improve this question
up vote 1 down vote accepted

For some reason wordpress don't honor Template_Hierarchy. The best way to get around this problem is to "force" wordpress to use the custom single.php template that you created. To accomplish that, add the following function underneath your CPT.

   /* Information Posts Template selection - a single.php just for our wrestler_profiles */
function pietergoosen_info_template_include( $original_template ) {
    if ( isset( $wp->query_vars['wrestler_profiles'] ) && false == $wp->query_vars['wrestler_profiles']  ) {
        return get_template_directory() . '/single-wrestler.php';
    } else {
        return $original_template;

add_filter( 'template_include', 'pietergoosen_info_template_include' );

Just remember, if you are using your CPT in a child theme or in a plugin, change get_template_directory() accordingly

share|improve this answer
Thanks, it works! – Hardeep Asrani Mar 16 '14 at 9:52
Glad I could help. – Pieter Goosen Mar 16 '14 at 9:54

I'm a bit late to the game, but I thought it was worth noting for future reference that your custom post type is called "wrestler_profiles" and your template is "single-wrestler.php." Your template should be named "single-wrestler_profiles.php" to match your custom post type name. As per the template hierarchy (http://codex.wordpress.org/Template_Hierarchy), to override the single template for a custom post type the name should be "single-$posttype.php"

If you were adding the custom post type via a plugin, Pieter's excellent solution is the only one I have found that works.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.