Forum Moderators: coopster

Message Too Old, No Replies

Display comment in categories? (wordpress)

         

FlashDriveDT

3:03 pm on Apr 2, 2011 (gmt 0)

10+ Year Member



I would like to display comments on category pages (wordpress blog). Currently my categories show 3 posts in full - except for the comments. It only gives the option to add comments and show how many comments have been left. I know this is the default. But how do I change it?

I figure I only need to tweak the index.php? First of all here's the original code from my theme:

<?php get_header(); ?>
<?php get_sidebar(); ?>

<!-- Content -->
<div id="content">

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<!-- Post -->
<div class="post" id="post-<?php the_ID(); ?>">
<div class="post-date"><?php the_time('F d, Y') ?></div>
<div class="post-title" style="text-align: center;">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="post-title-info">Posted by: <?php the_author() ?> : Category: <?php the_category(', ') ?></div>
<div class="clear"></div>
</div>
<div class="post-entry">
<?php the_content('Read more...'); ?>
</div>
<div class="post-info">
<?php comments_popup_link('Comments (0)', 'Comment (1)', 'Comments (%)'); ?> : <a href="<?php the_permalink() ?>#respond">Add Comment</a>
</div>
</div>
<!-- /Post -->
<?php endwhile; ?>
<!-- Navigation -->
<div class="navigation">
<div class="navigation-previous"><?php next_posts_link('« Previous Entries') ?></div>
<div class="navigation-next"><?php previous_posts_link('Next Entries »') ?></div>
</div>
<!-- /Navigation -->
<?php else : ?>
<!-- Post -->
<div class="post">
<div class="post-title">
<h2>Not Found</h2>
</div>
<div class="post-entry">
<p>Sorry, but you are looking for something that isn't here.</p>
</div>
</div>
<!-- /Post -->
<?php endif; ?>

<div class="clear"></div>

</div>
<!-- /Content -->

<?php include (TEMPLATEPATH . '/sidebar-right.php'); ?>
<?php get_footer(); ?>


Simply going by the code of the single.php I deleted the comment pop up part and replaced it with this (right under <?php the_content('Read more...'); ?>):


<?php get_header(); ?>
<?php get_sidebar(); ?>

<!-- Content -->
<div id="content">

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<!-- Post -->
<div class="post" id="post-<?php the_ID(); ?>">
<div class="post-date"><?php the_time('F d, Y') ?></div>
<div class="post-title" style="text-align: center;">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="post-title-info">Posted by: <?php the_author() ?> : Category: <?php the_category(', ') ?></div>
<div class="clear"></div>
</div>
<div class="post-entry">
<?php the_content('Read more...'); ?>
<?php edit_post_link('Edit this entry.','',''); ?>
<?php comments_template(); ?>
</div>
</div>
<!-- /Post -->
<?php endwhile; ?>
<!-- Navigation -->
<div class="navigation">
<div class="navigation-previous"><?php next_posts_link('« Previous Entries') ?></div>
<div class="navigation-next"><?php previous_posts_link('Next Entries »') ?></div>
</div>
<!-- /Navigation -->
<?php else : ?>
<!-- Post -->
<div class="post">
<div class="post-title">
<h2>Not Found</h2>
</div>
<div class="post-entry">
<p>Sorry, but you are looking for something that isn't here.</p>
</div>
</div>
<!-- /Post -->
<?php endif; ?>

<div class="clear"></div>

</div>
<!-- /Content -->

<?php include (TEMPLATEPATH . '/sidebar-right.php'); ?>
<?php get_footer(); ?>


Well, this doesnt work. The funny thing is that the added "edit this entry" function does show on the categories now but the comments dont. Of course it also doesnt show the pop up option anymore just like I wanted it. So what am I missing? Is there something else in wordpress or my theme that may be suppressing the comments display on categories? I cant seem to find anything in the index.php, comments.php or functions.php that may lead to that conclusion. But maybe its something else? Also, Ive tried to find a plugin that would do this but no luck...does anyone know of one? Like an enhanced category or comments plugin. Thanks for any help!

coopster

3:49 pm on Apr 28, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you certain you are accessing the correct table and/or column name in the WP database?

rocknbil

5:26 pm on Apr 28, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You shouldn't tweak any of the core code in Wordress, especially considering that they update the %$^$%^ thing like every other week. I just went through a long list of site WP updates and they came out with an update the very next day. Arg. :-)

I've done this and chasing the mods is a pain. It's on my regret list.

What you should really, really try to do is modify only your theme, which doesn't get zapped with every update. Have you given this a shot, implementing a snippet at the appropriate place in your theme?

wp_list_comments() [codex.wordpress.org]

Alternatively you can mod the functions.php within your theme for custom output, which also doesn't get killed with updates.