Link to home
Start Free TrialLog in
Avatar of jbrashear72
jbrashear72

asked on

how do I Setup templates for WordPress 3.0 Custom Post Type?

I created a post type called Surgeons and I want to set a spacific template for this page type.
It looks like it is just using single.php as the template. How do I change this to a spacific one of my choosing?

Here is the code I added to the functions.php
add_action( 'init', 'create_my_post_types' );    

function create_my_post_types() {
    register_post_type( 'Surgeons',
        array(
            'labels' => array(
                'name' => __( 'Surgeons' ),
                'singular_name' => __( 'List Surgeons' )
            ),
            'public' => true,
            'hierarchical' => true,
            'show_ui' => true,
            'publicly_queryable' => true,
            'exclude_from_search' => false,
            'menu_position' => 5,
            'supports' => array( 'title', 'editor', 'comments', 'trackbacks', 'author', 'excerpt', 'custom-fields', 'thumbnail' ),
            'rewrite' => array( 'slug' => 'mypage', 'with_front' => false ),
        )
    );
}

Open in new window

Avatar of jeremyjared74
jeremyjared74
Flag of United States of America image

Copy the index.php file and paste it into a text editorl
Add this to the very top:
<?php
/*
Template Name: Surgeons
*/
?>

Open in new window

Then name the file as surgeons.php and add it to your theme folder. You will now have the option to use this page template from the page editor page type drop menu.
Avatar of jbrashear72
jbrashear72

ASKER

But this is a post not a page. the drop down for templates does not show up.

I was told that if I added a file called single-Surgeons.php that this would work but that is being ignored too.
ASKER CERTIFIED SOLUTION
Avatar of jeremyjared74
jeremyjared74
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial