WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Comment Count (5 posts)

  1. chanel
    Member
    Posted 5 years ago #

    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:
    http://diaryofchanel.com/archives/
    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.

  2. jcow
    Member
    Posted 5 years ago #

    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?

  3. chanel
    Member
    Posted 5 years ago #

    http://diaryofchanel.com/discuss 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:

    <?php
    /*
    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">
    <?php
    if($post->post_parent)
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
    else
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    if ($children) { ?>

      <?php echo $children; ?>

    <?php } ?>

    </div>

    </div>
    <?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>
    </div>

    </div>
    <?php get_sidebar(); ?>

    <?php get_footer(); ?>

  4. jcow
    Member
    Posted 5 years ago #

    Try this:

    <div class="entrytext">
    				<?php $children = get_pages('child_of='.$post->ID);
    				if ($children) : ?>
    				<ul>
    				<?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; ?>
    				</ul>
    				<?php endif; ?>
    			</div>

    I tested it and it worked for me.

  5. chanel
    Member
    Posted 5 years ago #

    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.

    Excellent.

Topic Closed

This topic has been closed to new replies.

About this Topic