WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type Template Redirect
Why do you need this? (2 posts)

  1. Tammy Hart
    Member
    Posted 4 years ago #

    All you have to do is create a simple called single-POSTTYPE.php (ig, single-books.php), so why do you need this plugin?

    http://wordpress.org/extend/plugins/custom-post-type-template-redirect/

  2. DavidPilcher
    Member
    Posted 3 years ago #

    The single-POSTTYPE.php option also works in child themes whereas the plugin only finds the file if it's in the main theme directory.

    You should use locate_template() instead of TEMPLATEPATH to make it available to child themes.

    Not the tidiest of code, but it works:

    $testing = locate_template(array($wp->query_vars["post_type"] . '.php'));
    if ( $testing <> "" ) {
    $cptdt_template = $testing;
    }else{
    $testing = locate_template(array('t_' . $wp->query_vars["post_type"] . '.php'));
    if ( $testing <> "" )
    $cptdt_template = $testing;
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic