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 are 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 the best landing page builder on the market and makes it easy to create a fully custom WordPress theme, including a custom homepage. 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.

With that done, click to select the widget in the page preview.

The WordPress recent comments widget

You can now change how many comments appear on your homepage, using the ‘Number of comments to show’ field.

You can also add an optional title, which will appear above the latest comments.

Adding a title to a recent comments widget

When you’re happy with how the widget is set up, you can change how it looks by clicking on the ‘Advanced’ tab.

Here, you can change the text color, font, spacing, and more.

Customizing the latest comments widget

You can even draw attention to the recent comments by adding CSS animations.

As you make changes, you can click on the ‘Apply’ button to see those changes in the live preview. This allows you to try different settings to see what looks the best.

How to customize latest comments on a WordPress homepage

When you’re happy with how the custom homepage looks, it’s time to publish it by clicking on the ‘Save’ button.

Then, choose ‘Publish.’

Publishing a list of latest comments on a custom homepage

After publishing your design, you’ll need to tell WordPress to use it as your new homepage.

To do that, simply go to Settings » Reading in the WordPress dashboard.

How to change the homepage settings in WordPress

Here, scroll to ‘Your homepage settings’ and select ‘A static page.’

You can now open the ‘Homepage’ dropdown and choose the page that you want to use as the new homepage.

Setting a static page as the homepage

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.

The WordPress full site editor

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 are 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 that 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. This is safer because there’s no risk of breaking the parent theme, and you won’t lose your changes the next time 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.

Now, open the index.php file in a 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:

$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 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. Here's our editorial process.

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

33 CommentsLeave a Reply

  1. Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!


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


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


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

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

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

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

  8. Use:

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

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

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

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



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.