ThemeShaper Forums » Thematic

[closed]

Make a category template display post AND comments

(3 posts)
  • Started 4 years ago by Manuel
  • Latest reply from Manuel
  • This topic is resolved
  1. I’ve created a new category template (named category-15.php) and put it in my childtheme directory. I thought the easiest way to make it act like single.php (so it displays the post and the comments) is to just copy the code from single.php, but that is not working, in fact, it changes nothing.

    I need this because in this sites navigation pages are considered as “core information links” and the categories just as extras which contain no important stuff about the business.

    This one specific category I am talking about here contains only one post, called “The Guestbook”. After clicking the category link in the nav — which is named just like the post — one should see the post with all the comments as well.

    This is the code content of category-15.php

    <?php
    /*
    Template Name: Guestbook Template
    */
    ?>
    <?php
    global $options;
    foreach ($options as $value) {
        if (get_option( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; }
        else { $$value['id'] = get_option( $value['id'] ); }
        }
    ?>
    <?php get_header() ?>
    
    	<div id="container">
    		<div id="content">
    
    <?php the_post(); ?>
    			<?php thematic_navigation_above();?>
    
    <?php get_sidebar('single-top') ?>
    
    <?php thematic_singlepost() ?>
    
    <?php get_sidebar('single-insert') ?>
    
    			<?php thematic_navigation_below();?>
    
    <?php thematic_comments_template(); ?>
    
    <?php get_sidebar('single-bottom') ?>
    
    		</div><!-- #content -->
    	</div><!-- #container -->
    
    <?php thematic_sidebar() ?>
    <?php get_footer() ?>
    Posted 4 years ago #
  2. Wheee, I fixed something myself. :)

    Apparently there was only one tiny thing missing. Inside of the WordPress core file “comment-template.php” is one line that says if ( ! (is_single() || is_page() || $withcomments) ) (which disables the display of comments if one is not viewing a single post or a page).

    So all I had to do was to add an override of that variable to my category template: <?php $withcomments = 1 ?> — and comments got pulled in.

    Here is my working category template with comments:

    <?php
    /*
    Template Name: Category with Comments
    */
    ?>
    <?php
    global $options;
    foreach ($options as $value) {
        if (get_option( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; }
        else { $$value['id'] = get_option( $value['id'] ); }
        }
    ?>
    <?php get_header() ?>
    
    <?php $withcomments = 1 //This one displays comments even if we are in category view ?>
    
    	<div id="container">
    		<div id="content">
    
    <?php the_post(); ?>
    			<?php thematic_navigation_above();?>
    
    <?php thematic_singlepost() ?>
    
    			<?php thematic_navigation_below();?>
    
    <?php thematic_comments_template(); ?>
    
    		</div><!-- #content -->
    	</div><!-- #container -->
    
    <?php thematic_sidebar() ?>
    <?php get_footer() ?>

    Man, kinda cool to figure something out on your own. :D

    Posted 4 years ago #
  3. Example link (with image upload for comments as well)
    http://ads-rantum.de/_neu/extras/gaestebuch/

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.