WordPress.org

Ready to get started?Download WordPress

Forums

Child Theme Post Templates (5 posts)

  1. Paul Whitener Jr.
    Member
    Posted 4 years ago #

    I'm having an issue using single post templates within a child theme. I've added the proper code to my child theme's functions.php file (add_filter('single_template'...) and have the proper single-XX.php files created but they're not being found/used.

    I've done some reading and it appears as though the solution used thus far to resolve this is to place any post templates within the parent theme. I'm wondering if there's a better solution? Is there a way to modify the single-template filter to look within the child theme's directory, perhaps by replacing "TEMPLATEPATH" with something else? I've tried a few modifications (such as hardcoding the path to the child theme directory) but nothing's working.

    Any help is appreciated, thanks..... Paul

  2. roburdick
    Member
    Posted 4 years ago #

    I have exactly the same issue!
    http://www.robertburdick.com

  3. roburdick
    Member
    Posted 4 years ago #

    change TEMPLATEPATH to STYLESHEETPATH

    I Ended up using this code in my single.php (right at the top):

    '<?php
    $category = get_the_category();
    $currentcat = $category[0]->cat_ID;
    ?>
    <?php
    $category = get_the_category();
    $currentcat = $category[0]->cat_ID;
    if (file_exists(STYLESHEETPATH."/single-$currentcat".".php")) {
    include(STYLESHEETPATH."/single-$currentcat".".php");
    } else {
    ?>'

    remember to put this right at the bottom

    '<?php } ?>'

    http://wordpress.org/support/topic/344132?replies=3
    http://www.webloglines.com/blog/stuff/article/wordpress_single_post_templates.php
    http://lists.automattic.com/pipermail/wp-hackers/2009-May/026282.html

  4. Paul Whitener Jr.
    Member
    Posted 4 years ago #

    Works perfectly, thanks!

  5. transmothra
    Member
    Posted 4 years ago #

    Thanks roburdick, this helped me too!

Topic Closed

This topic has been closed to new replies.

About this Topic