Support » Fixing WordPress » Comment Count

  • Resolved chanel


    I would like to have the amount of comments a page has when it’s being shown as a list. For example:

    Like you see here with my archives list:
    where it says “Blog Post – (23 cmnts)”

    I would like do that for a Page that has a SUBPAGE list.

    I’ve been trying to find a solution to this for more than 2 weeks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • I don’t fully understand what you are trying to do. You want to show how many subpages a page has? or how many comments it has?

    How are you listing the pages currently? is the page I am referring to.
    That particular page has subpages. So far I only have 2 listed like this

    1. domestic violence
    2. abortion

    Ideally, i would like to show on my Discuss page, how many comments each SUBPAGE/TOPIC has. ie:

    1. domestic violence (18 comments)
    2. abortion (32 comments)

    Here is how I have the Discuss page coded, with it’s own template:

    Template Name: Discussions

    <?php get_header(); ?>

    <div id=”side-left”>
    <div id=”content”>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class=”kutu”>
    <div class=”ust”><span></span></div>

    <div class=”post” id=”post-<?php the_ID(); ?>”>
    <h2 class=”pagetitle”><?php the_title(); ?></h2>
    This section is an open forum for viewers to discuss & debate random topics per week. I will be posting “The Topic Of The Week” as it will allow us to converse about highlights of the media, politics, celebrity gossip, life & relationships, and parenting. Topics are posted in a numerical order (the highest number being the most recent topic) For those that are subscribed, you will receive an email notification when the new topic is posted! So if you’re interested in being involved, please subscribe to my mailing list. Thank you.

    <div class=”entrytext”>
    $children = wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0″);
    $children = wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″);
    if ($children) { ?>

      <?php echo $children; ?>

    <?php } ?>


    <?php endwhile; endif; ?>
    <?php edit_post_link(‘Edit this entry.’, ‘<p style=”margin:10px;”>’, ‘</p>’); ?>
    <br class=”clear” />
    <div class=”alt”><span></span></div></div>

    <?php get_sidebar(); ?>

    <?php get_footer(); ?>

    Try this:

    <div class="entrytext">
    				<?php $children = get_pages('child_of='.$post->ID);
    				if ($children) : ?>
    				<?php foreach ($children as $post) : setup_postdata($post); ?>
    					<li class="page_item page-item-<?php echo $post->ID; ?>"><a href="<?php echo get_permalink($post->ID); ?>" title="<?php echo get_the_title($post->ID); ?>"><?php echo get_the_title($post->ID); ?></a> (<?php comments_number('0', '1', '%' ); ?> comments)</li>
    				<?php endforeach; ?>
    				<?php endif; ?>

    I tested it and it worked for me.

    It worked wonderfully jcow!! Thank you so much for the help. I’ve tried using the comment loop before, but I didn’t know how to place it right. I see all I was missing was ( ) all along.


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Comment Count’ is closed to new replies.