Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Show Comments on the Homepage of Your WordPress Theme

Do you want to show comments on the homepage of your WordPress theme?

By adding comments to this important page, you can make a great first impression with new visitors, while also encouraging users to join in the conversion.

In this guide, we’ll show you how to add comments to the homepage of any WordPress theme, even if your theme doesn’t support it by default.

How to show comments on the homepage of your WordPress theme

Why Show Comments on Your Homepage?

Comments are the easiest way for visitors to communicate with you and each other. They allow visitors to send feedback, ask questions, and offer their point of view.

If your posts are getting lots of comments, then it’s a sign that you’re building an active community around your WordPress blog. With that in mind, you may want to make these comments more visible and prominent by displaying them on your homepage.

The homepage is often the first thing that new visitors see, so comments can be a form of social proof that encourages first-time users to check out more of your site. It also makes it easier for users to see the latest conversations, and get involved in the discussion.

If your theme lets you add widgets to your homepage, then you can simply add comments in the sidebar area. However, not all themes support homepage widgets.

In this guide, we’ll show you how to add comments to the homepage, no matter what WordPress theme you’re using. You can use the quick links below to jump straight to the method you prefer.

Method 1. Showing Comments on Your Homepage Using the Latest Comments Widget

WordPress comes with a built-in Latest Comments widget that you can add to any widget-ready area.

To learn more, please see our complete guide on how to add WordPress widgets.

If your theme doesn’t support homepage widgets, then we recommend creating your own homepage design using a page builder plugin.

SeedProd is is the best landing page builder on the market and makes it easy to create a fully custom WordPress theme, including a custom homepage template. For more information, please see our guide on how to edit a WordPress homepage.

After creating your homepage design, simply scroll to the ‘Widgets’ section in SeedProd’s left-hand menu.

Adding the Latest Comments widget using SeedProd

Here, just find the Recent Comments widget and add it to your layout using drag and drop.

SeedProd is a flexible and powerful page builder so you can add the widget anywhere on the page and then use the built-in tools to style the widget however you want.

Configuring the recent comments widget in WordPress

Another option is to use Full Site Editing (FSE) and the block editor.

This method doesn’t work with every theme, but if you’re using a block theme, then you can add the widget to your homepage by going to Appearance » Editor.

Opening the full site editor in WordPress

This should launch the full site editor with your theme’s homepage template already selected.

In the top-left corner, click on the blue ‘+’ button.

Adding blocks using Full Site Editing (FSE)

Start typing ‘Latest Comments’ into the search bar.

When the right block appears, simply drag and drop it onto your layout.

Adding a Latest Comments block in WordPress

After adding this block, you can configure the Latest Comments widget using the settings in the left-hand menu.

For example, you can change how many comments the widget displays, hide visitor avatars, and more.

Configuring the latest comments on your WordPress homepage

When you’re happy with how the comment section is set up, simply click on the ‘Save’ button. Your WordPress website will now be showing the latest comments on the homepage.

Method 2. Showing Comments on Your Homepage Using Code

If you’re not using a block-based theme, then you can add comments to the homepage using a code snippet.

This does involve editing your theme files, so it isn’t the most beginner-friendly method. Adding code to your site can also cause problems including common WordPress errors.

With that being said, it’s a good idea to create a backup so you have something to restore in case you get any errors.

If you don’t already have a backup plugin installed on your site, then see our expert pick of the best WordPress backup plugins.

Pro Tip: Instead of modifying files inside a theme, we recommend creating a child theme and then adding the code snippet there instead. This is safer because there’s no risk of breaking the parent theme, and you won’t lose your changes whenever you update the parent theme.

If this is your first time adding code to your WordPress files, then you can check out our guide on how to copy paste code snippets in WordPress.

To add the comments to your homepage, you’ll need to edit the index.php file. To access this file, you’ll use an FTP client such as FileZilla, or you can use the file manager of your WordPress hosting cPanel.

If this is your first time using FTP, then you can see our complete guide on how to connect to your site using FTP.

Inside the FTP client, go to wp-content/themes.

Connecting to your site using an FTP client

You can then open the folder for your current theme and find the index.php file.

Then, open the index.php file in any text editor such as Notepad.

Adding comments to your WordPress theme using code

After that, go ahead and add the following code snippet inside the WordPress Loop. This will typically be either right before the endwhile statement or the else statement:

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

For example, in the TwentyTwenty-One theme, you’ll need to add the code snippet after twenty_twenty_one_the_posts_navigation(); and before the } else { statement, as you can see in the following image:

Showing comments on the homepage of a WordPress theme

After that, simply save the index.php file. Now if visit your WordPress site, you’ll see the comments displayed on the homepage.

If you created a child theme and don’t see comments on the homepage after adding the code snippet, then you may need to add an extra line of code.

If this is the case, then go ahead copy and paste the following code into your theme’s index.php file:

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

We hope this tutorial helped you learn how to add comments to your WordPress theme’s homepage. You may also want to learn how to create a free business email address, or check out our list of must have plugins to grow your site.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

32 CommentsLeave a Reply

  1. working fine, but here shows 100s of comments how can i disable comments or else remove comments in code

    • You would remove the code if you no longer want to show the comments on your homepage

      Admin

  2. Hy,
    Please where exactly am I adding the code? is it on my index.php? or front-page.php or where else?

    I’m not good at coding but I can locate the files please

    • If your theme has a front-page.php you would add it to that file for your static home page

      Admin

  3. 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.

  4. 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?

  5. 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 :)

  6. 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;

  7. Use:

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

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

  8. 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 :)

  9. 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)

    Cheers,

    Mitch

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.