How to support custom templates on a custom post type?

I’m stucked at some point developing my theme.

I created a custom posts types to support an image gallery. So far, it’s working great (have a look on ‘galeria’ on psaikali.com).
I registered this custom post type (register_post_type( ‘artwork’, $args )) and activated the ‘page attributes’ function, to define a different template for my posts (‘supports’ => array( ‘title’, ‘editor’, ‘thumbnail’, ‘page-attributes’, ‘custom-fields’ )).

Read More

But it just shows the ‘order’ of the page, not the ‘template selection’ part. Does anyone knows what’s wrong ? I did create the template file called single-artwork.php …

Screenshot of the page attributes page I see : http://img213.imageshack.us/img213/5348/notemplate.jpg

Thanks for the help !

Related posts

Leave a Reply

2 comments

  1. You should be able to create a single-your-post-type-name.php file and have it work. I currently have it working fine on 3 or 4 sites so if it’s not working for you you’re doing something wrong.

    Based on your code sample single-artwork.php should work as a single page post template. You could also redirect on single.php with:

    <?php
    if( get_post_type() == 'artwork' ) {
    include_once ( TEMPLATEPATH.'/path/to/template.php' );
    } else {
    include_once( TEMPLATEPATH.'/normal/template.php' );
    }
    ?>
    

    I’d prefer to see the single-posttype.php route since WordPress is doing the routing at a deeper level and it’s always nicer to just use WordPress built in stuff.

  2. well single-POSTTYPE.php is for the single view of that post type.
    Do you actually have a file my-custom-template.php which looks like this?

    /*
    Template Name: My Custom Template
    */