Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Show Comments on the Homepage of Your WordPress Theme

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Show Comments on the Homepage of Your WordPress Theme

Recently while working on a very secret project, we found a need to show comments on the homepage of the site. Normally, on single pages you can just call comments_template(); and it should display, but it wasn’t showing up. All we ended up getting was a blank div container. After doing a quick search online, we were able to find the answer. In this article, we will show you how to show comments on the homepage of your WordPress site.

Inside the loop right before endwhile, simply add the following code:

$withcomments = "1";
comments_template(); // Get wp-comments.php template ?>

A single line $withcomments makes all the difference.

Note: this was a very simple one page site we threw up. So the theme elements were style.css, index.php, and comments.php file. We were calling a loop to display a specific page on the index.php file along with other things.

We hope that this would help some of you. Some of you may even have a better way of doing this. If you do, please share it with us in the comments.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Michelle says:

    I’m sorry if I sound dumb, but I’m not a PHP coder. Can someone please tell me which file I need to edit in order to place this text?

    Thank you very much.

  2. Piet says:

    Very useful! Thanks

  3. DebJ says:

    I’m not sure exactly where to add this code. I have the comment box code at the end of my post, but where do I put this? Before or after?

  4. Chris says:

    Works great! Is there a way so when clicking post comment it won’t redirect to the posts page?

  5. Big Tom says:

    Has anyone had trouble getting this to work with Disqus?

  6. Faiz Ahmed (KUET) says:

    That was excellent .. exactly i wanted it. Thanks thanks.

  7. Trisha says:

    Thanks for the great tip (and generally fantastic resource), it set me in the right direction when I needed to create a modification for a child theme (using Genesis as the parent theme) I needed to use the following to get the comments to display:

    global $withcomments;
    $withcomments = 1;
    comments_template( ' ', true );

    I hope this helps someone else spend less time on this problem than I did :)

  8. Trisha says:

    Recently, when I was trying to solve this problem in a child theme I needed to add this line above the two shown above in order to get it work:
    global $withcomments;

  9. Jerad says:

    Thank you! The $withcomments = “1”; bit was exactly what I needed.

  10. John says:


    comments_template(“/comments.php”, true);

    otherwise it just repeats the first posts comments for every post.

  11. Japh says:

    Great tip, thanks for posting about it too. I’ve noticed questions about this in the WordPress Support forums a few times with no answer given, so this will no doubt help quite a few people :)

  12. Faizan Elahi ( BestBloggingTools) says:

    Nice tip !

  13. jauhari says:

    Thanks… let’s me try it

  14. Da'Scott Says Ifihadarockidbussyoheadbich says:

    Just starting with wp so yes i need it thanx

  15. Mitchell Allen says:

    Cool tip. At long last, I’m beginning to dig a little deeper into the WordPress code. I’ve subscribed to your weekly updates! dragonblogger mentioned your blog today and then I saw this tweet in my Gmail (I use @Rapportive)



Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.