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().
Thank you very much, vtxyzzy!
It should work 😉
Ops! Accually not, vtxyzzy. Because I want to call the comments number of a post OUTSIDE the loop – in the sidebar.
Sure, just get the number inside the loop, and save it to a global variable. Then retrieve the variable in the sidebar.
(@danielsl)
13 years, 10 months 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?