WordPress.org

Ready to get started?Download WordPress

Forums

Display comment count next to posts? (5 posts)

  1. Floyd3
    Member
    Posted 1 year ago #

    Hi,

    I'd like to add another column to the page here which displays the comment count of each of the posts (guitar tabs) listed there.

    Basically I just want add a new column header that says "Comments" (next to "Title, Rating", "Views" and "Notes") and then next to each tab, it will say "0" or "1" or "5" etc... or however many comments are on that guitar tab/wordpress post.

    I found a wordpress function called "get_comments_number" that I think will do this, but I can't get it to work.

    Here is the code I tried:

    <?php $commentscount = get_comments_number(278); echo $commentscount; ?>

    With "278" being the post ID... and I was going to change that post ID to each different unique post ID, but I couldn't get it to work.

    So my question is:

    Is this the right function I should be using? If so, what is wrong with my code? I feel like it's close, I probably just need to change 1 little thing. Am I not able to put this php code inside a wordpress page or something maybe?

  2. Floyd3
    Member
    Posted 1 year ago #

    Not sure if this matters but the guitar tabs are wordpress posts, and the guitar tab listing page is a page.

  3. Floyd3
    Member
    Posted 1 year ago #

    Is it possibly a different function all together?

  4. Floyd3
    Member
    Posted 1 year ago #

    Anyone have any ideas? I still cant figure this out.

    I probably over-explained the problem, lol...

    I just need to know the code to display the number of comments in a particular post.

  5. cykeltomte
    Member
    Posted 1 year ago #

    Have you tried using just comments_number() ? http://codex.wordpress.org/Function_Reference/comments_number

    If I understand your question this could be de easiest way of displaying the number of responses/comments.

Topic Closed

This topic has been closed to new replies.

About this Topic