Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Show Comments on the Homepage of Your WordPress Theme

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

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

Adding comments to the homepage can make a great first impression with new visitors while encouraging users to join in the conversion.

In this guide, we will 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 are 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.

In this guide, we will 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 Block

WordPress comes with a built-in Latest Comments block that you can add to any page or post.

There are three ways to use them: adding the block as a widget in the sidebar, adding the block in the WordPress full site editor, or adding the block using a page builder plugin.

Using the Latest Comments Block as a Homepage Sidebar Widget

If your theme lets you add WordPress widgets to your homepage, then you can simply add the Latest Comments block as a sidebar widget.

For more information about this, you can follow our guide on how to show recent comments in the WordPress sidebar.

However, not all themes support adding widgets to any pages. If you are experiencing this issue, we recommend creating your own homepage design using the WordPress Full Site Editor or page builder plugin.

Using the Lates Comments Block in the Full Site Editor

If you are using a WordPress block theme, then you can add the Latest Comments block to your homepage using the Full Site Editor.

To access the editor, simply go to Appearance » Editor.

Navigating to the Full-Site Editor from the WordPress dashboard

From here, go ahead and select ‘Pages.’

This is where you’ll see all the pages that exist on your WordPress website.

Choosing Pages in the Full Site Editor

Up next, select your theme’s homepage.

In this case, it was ‘Blog Home,’ and it was already set as the front page of the website, as marked by the house icon.

Selecting Blog Home page in the Full Site Editor

Now, simply click the pencil ‘Edit’ icon next to the name of the page.

This will direct you to the editing interface.

Selecting the pencil edit button to edit the Blog Home page in the Full Site Editor

At this point, go ahead and click on the blue ‘+’ button in the top left corner.

This button will show you all the blocks available to use for your page.

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

Using the Latest Comments Block in a Page Builder

The second method is great if you are happy with the customization options of the WordPress Full Site Editor. However, if you are looking to elevate your design, we recommend using a page builder plugin.

SeedProd is the best page builder on the market and makes it easy to create a fully custom WordPress theme, including a custom homepage.

For more information about creating a homepage with SeedProd, 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 are 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 are 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

Method 2: Showing Comments on Your Homepage Using Code

Another way to show the most recent comments on your homepage is to use code.

This method is recommended if you are comfortable with coding and your custom theme doesn’t support the Latest Comments block or widget.

Do note that 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:

<?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 you 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

Bonus Tip: Use a Comment Plugin to Boost Your Engagement

If you want to get more people commenting on your website, try installing a comment plugin. Besides comment moderation, these plugins come with features to encourage more conversations on your Website.

Take Thrive Comments, for example, which is the best comment plugin on the market.

The Thrive Comments WordPress plugin

This plugin can boost user engagement by adding likes and dislikes as well as voting and badges. This way, fellow users can show appreciation for comments they find most useful.

Additionally, you can see the performance of your comments, including which pages are getting the most action and which commenters are the most active. This information can help you figure out how to optimize your content for engagement even further.

We hope this tutorial has helped you learn how to add comments to your WordPress theme’s homepage. You may also want to check out our guide on how to moderate comments in WordPress and our list of must-have WordPress plugins to grow your website.

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.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

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. Syed Balkhi says

    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. venkatesh says

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

    • WPBeginner Support says

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

      Admin

  3. Stanislaus Okeke says

    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

    • WPBeginner Support says

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

      Admin

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

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

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

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

  8. John says

    Use:

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

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

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

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

    Cheers,

    Mitch

Leave a Reply to Piet Cancel 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.

WPBeginner Assistant
How can I help you?

By chatting, you consent to this chat being stored according to our privacy policy and your email will be added to receive weekly WordPress tutorials from WPBeginner.