WordPress.org

Support

Support » Themes and Templates » Thesis: Custom Post Type Templates

Thesis: Custom Post Type Templates

  • Hi,

    I’ve got a question regarding Thesis 1.8.2 and custom templates.
    I’ve created a custom post type and now I want to use a specific template for all the posts of that type. But I could’t figure out how to do with Thesis enabled. Without Thesis it’s no problem, but the Thesis Templating Engine seems makes it very complicated.

    One try was to check the requested URL for a slug, call my template via require() and then stop the php execution. But with Thesis enabled I end up getting a 301 redirect to my wordpress main page.

    function my_page( $post_id ){ // URI: /mySlugOfThatPostType/PostID
        $request = $_SERVER['REQUEST_URI'];
        $request = explode('/', $request);
    
        if($request[1] == 'mySlugOfThatPostType'){
            echo "would redirect...";
            $s = get_post($request[2]);
    
            if($s == false){
                echo "not found";
                // get_404_template();
                exit();
            }else{
                require(__DIR__.'/detail.template.php');
                exit();
            }
        }else{
            echo "go on...";
        }
    }
    add_action('init', 'my_page');

    Is there some error in there or is there a better way to use my template?

    I have to use Thesis (sadly) and I have to use my current wordpress version.
    Please help me.

    Regards,
    zed6colors

  • The topic ‘Thesis: Custom Post Type Templates’ is closed to new replies.