• Hello,

    We are in the process of building a blog using the Genesis Framework and Enterprise Child Theme via localhost. The task has been charged to me, but my background in code is minimal at best (so please keep this in mind in your replies). Customizing to date has been limited to using a variety of plugins and editing the CSS, but we need to have specific disclaimers show up underneath individual posts, with the text of those disclaimers dependent upon the content. From what I’ve seen, the best way to accomplish this seems to be via custom post templates.

    I tried the plugins Custom Post Templates and Single Post Templates, which worked. This is the gist of the code I used there:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    While this tactic worked, it also required manual assignment of templates on a post by post basis. Because using the wrong disclaimer can cost us tens of thousands of dollars, I would prefer to have the disclaimers automatically inserted, so I began to investigate how to use custom post templates by category.

    Initially, I tried using plugins, including Custom Post Templates by Cat, Custom Single Post Template manager, Ryan Boren’s Custom Post Templates, and Category Templates 2, editing the template and file names accordingly as I went. None worked. I then attempted a suggested edit to the functions.php file, again altering the names as required:

    add_filter('single_template', create_function('$t', 'foreach( (array) get_the_category() as $cat ) { if ( file_exists(TEMPLATEPATH . "/single-{$cat->term_id}.php") ) return TEMPLATEPATH . "/single-{$cat->term_id}.php"; } return $t;' ));

    It didn’t work. Other suggested methods edited the single.php file, but our child theme does not have one. Relying on the template hierarchy, I tried creating one, and inserting several variations of the following code:

    <?php
    $post = $wp_query->post;
    if ( in_category('9') ) {
    include(TEMPLATEPATH . '/single2.php');
    } else {
    include(TEMPLATEPATH . '/single1.php');
    }
    ?>

    It didn’t work. I also tried inserting it into the functions.php file. No dice. Someone suggested replacing “in_category” with “is_category”, which I did to no avail.

    Has this happened to anyone else? Is there a reason that none of the plugins intended to force the by-category template use wouldn’t work? Is there a change I need to make in Genesis, or a better piece of code to insert into functions.php? I’m sure it’s something humiliatingly simple and I’m just not seeing it, but any help or insight you can provide would definitely be appreciated.

Viewing 1 replies (of 1 total)
  • As this is a commercial theme and/or its template files are not publically accessible, you need to seek support from the theme vendors.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Template by Category using Genesis and Enterprise’ is closed to new replies.