WordPress.org

Ready to get started?Download WordPress

Forums

How to call comment number of single posts (5 posts)

  1. danielsl
    Member
    Posted 4 years ago #

    I know this is basic, but I couldn't do it anyway, so I will appreciate your answer.

    I listed some special posts in my sidebar, and after each post title/link I want to put the comment counter to that single post, with link to the #comments area. But I could not figure out what tags to use. It has to end up with something like:

    a href="POST URL#comments">COMMENT COUNTER FOR THIS SINGLE POST /a

    Please, how do I construct this link?

  2. vtxyzzy
    Member
    Posted 4 years ago #

    I don't know if this is what you want, but you can use comments_number() to get the number of comments for the current post.

    The post URL is obtained with get_permalink() or the_permalink().

  3. danielsl
    Member
    Posted 4 years ago #

    Thank you very much, vtxyzzy!

    It should work ;-)

  4. danielsl
    Member
    Posted 4 years ago #

    Ops! Accually not, vtxyzzy. Because I want to call the comments number of a post OUTSIDE the loop - in the sidebar.

  5. vtxyzzy
    Member
    Posted 4 years ago #

    Sure, just get the number inside the loop, and save it to a global variable. Then retrieve the variable in the sidebar.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags