Have you noticed Home Page of this blog? On the right of each Post Title you will see a balloon image which shows number of comments for the post. This is a hyper link, if clicked will take you to the comments section of the post.
Check right top of the image
Most of the themes comes with this feature. My theme also has these feature.
Now, I wanted to display the same type of Comments Link in Single Post.
This is what I did, I opened index.php theme file. Found the following code and copied it.
<div class="comm"><span><?php comments_popup_link('0', '1', '% '); ?></span></div>
Then, I opened single.php and pasted the code just above the title and saved the file.
I then opened the post in the browser to see the whether the comment link is appearing in the Single post or not.
I was surprised to see that there was no Comments Link in the post. Then, I opened the source code of the page, but was unable to find the code that i pasted.
After doing some research, I found out that Comments popup link will only work inside a loop. index.php uses the loop, but single.php (Single Post) doesn’t.
I found some clue to the solution. If you closely look at the start of the comments section below:
Display number of comments in comments header section
You can see that number of comments are displayed in the header of the comments section. I immediately headed to comments.php and found that there is a comments_number function which is outputting this. I then used that function to achieve my goal.
Do the following to add Comments Link in Single Post:
- Copy the below code.
<div class="comm"><span><?php comments_popup_link('0', '1', '% '); ?></span></div>Note: You have to use CSS classes to give the styling. Here, comm class is being used.
- Open single.php
- Paste it just above the title.
- Save the file
Try opening any post in your browser to see the change. If you see the comments link in the post, then you are done. Otherwise try checking what went wrong.
This how I used different function to display Comment link in single post!!!
I hope this helps…
If you have any doubts or suggestions, please do leave a comment.
Check out more tips on Wordpress!
Technorati Tags: wordpress, wordpress functions, wordpress tips
|
1921 readers are already subscribed to this blog! Why don't you be one of them? Subscribe to this blog via your favorite RSS feed reader or by entering your email address on the form below: |
You Should Also Check Out These Posts:
- How to Remove Wordpress Meta Generator tag
- Yahoo’s Digg alike called – Yahoo Buzz
- How to Beautify Code samples in your post using Syntax Highlighter
- Get more comments and visitors by using CommentLuv Plugin
- Give Reward to commentators – Use ‘NoFollow Free’ WP Plugin


Subscribe
Simple and great find nihar….
TechnoSamrats last blog post..Personalize & Create Desktop Widgets With 360desktop
@TechnoSamrat, Thanks…
Good tutorial! I like the way you explain what went wrong and how your corrected it. Your learning process sounds like mine – find an example of what works and use it on the page I want to edit.
Kim Woodbridges last blog post..5 Interesting WordPress Plugins
@Kim, thanks for the compliment. Hope this tutorial helps ppl who are looking for this.
This gives me solution for my other blogs!!
@Arun, I am glad that this helped you.
Good guidance given as usual. Thanks for sharing it.
Atnizs last blog post..What To Sell On Your Blog?
@Atniz, thanks.
It does add to the appearance to the overall look of the blog. Looks very easy to do and instructions are very good.
@Madmouse Blog, Yeah, you are right. But, it also adds a good navigation for those who want to directly jump to the comments section.
I like how your blog has the little speech bubble that displays the number of comments.
This code is also used for the most commented posts at the bottom of this page?
@Ryan, no, the most comment posts at the bottom of the page is a plugin that i have used. It can be also a piece of code that can be manually added.
Nice and clear tutorial. Write more Wordpress tutorials. They are really useful.
Steve Yus last blog post..How to Play FLV files in Windows Media Player?
@Steve Yu, Thanks for the appreciation. I will do.
nice tip but what about changed the color of the ballon ? or at least customize it .
but easy way to do it thanks
Money Academys last blog post..( New Tool ) Check your website position on Google from Blfree
@Money Academy, The balloon is a image. If you want other color then you may want to modify the image or try search on the web .
[...] How to add Comment Link in Single Post – Wordpress [...]
This is a little off the wall but have you checked out Zemanta yet for blogging? I know how you love your wordpress plugins, etc. so you should check it out. It’s a plugin that basically suggests relevant articles and images to your blog post as you write it. Definitely a handy tool that adds depth to my blogging. You should give it a try Nihar.
@Wade Briggs, thanks for the information. I will have a look at it.
Great tip Nihar. I had a feeling it had something to do with the loop. Good thing I found your article. I love your explanation, simple and straight to the point! Thank you for sharing.
Raymond Seldas last blog post..PHP Contact Form with JQuery Validation
@Raymond, Thanks for the compliment. I hope you check out the blog more often.
[...] How to add Comment Link in Single Post – Wordpress [...]
Nice and clear really useful.It has good navigation for those who want to directly jump to the comments section.
@Image Editing Service, Glad that it was useful to you.
know how you love your wordpress plugins, etc. so you should check it out. It’s a plugin that basically suggests relevant articles
@enver, Thanks will check it out.
Hi, a happy new year to everybody.
Sorry, probably I missed something because everybody says it is easy, but I can’t implement it.
The fonction comment_popup_link(), which is in the code to be copied and pasted, does not work, as it is said at the beginning.
As for the comments_number() function, it displays the number, but it is not a link. …
So, what is to be copied and where ?
@gabier, you need to use a href tag to get the link to that comment number.