WordPress.org

Ready to get started?Download WordPress

Forums

Add Comment Count to About Page (7 posts)

  1. almodesto
    Member
    Posted 5 years ago #

    hello,
    i have enabled comments on my "about" page and would like to include a counter as well. for each post on my main page there is a comment counter next to the post theme and i would like to have my "about" page set up likewise. i looked thru archives and did not see this addressed. i originally posted this the evening of friday 21nov but it mysteriously vanished over night! thanks.

  2. almodesto
    Member
    Posted 5 years ago #

    is there no one who is willing to help? if this is the wrong forum or it simply cannot be done please advise. thank you

  3. wiziology
    Member
    Posted 5 years ago #

    hey man, just came across your post, try using the following code within the loop.

    <? $comment_count = $post->comment_count; ?>

  4. almodesto
    Member
    Posted 5 years ago #

    thanks Wiz for answering, to be honest i had given up on any help! one question, what do you mean by "within the loop?" as you can see i am a neophyte. thanks again.

  5. wiziology
    Member
    Posted 5 years ago #

    No problem man, just remember to be patient when you post on here. Hundreds of people are posting questions every day, so it's very easy for one to get lost in the mix. Eventually, someone will find it!

    To answer your question, the loop is what retrieves post or page information.

    The loop starts with:
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    and ends with:

    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    1) Copy page.php template from your template directory. At the very top of the file, add this to the very first line:

    /*
    Template Name: About Page
    */

    After the line with the_post() and before the first endwhile, add this line:

    <?php
    echo $post->comment_count;
    ?>

    Save the file as about.php and upload it to your current template directory. Login to your WordPress admin page and go to manage pages to select your about page. This will bring up the page editor. You will have your title and page content. Well below that, you will see a section saying "Page Template". Click the dropdown box and select About Page. Now your about page will load the about.php file instead of the standard page.php

    You can read about the loop here:
    http://codex.wordpress.org/The_Loop

    Hope this helps.

    - The Wiz

  6. jbjweb
    Member
    Posted 5 years ago #

  7. almodesto
    Member
    Posted 5 years ago #

    many thanks again Wiz for your help and advice! i try to be patient i do realize that there are an enormous amount of people looking for help. i will try your suggestion first chance i get.
    also thanks to you "jbjweb" for your input. i will certainly read it, i need all the help i can get!

Topic Closed

This topic has been closed to new replies.

About this Topic