Displaying the Comments block in Block Themes
In this tutorial, we are going to take a closer look at how post comments are displayed when you are using a block theme.
- Managing the Comments block via the Site Editor and Template Editor.
- Using the list view to gain a clear picture of the structure of the single template.
- Identifying the implications of removing the Comments block.
- Creating a custom template and adding a Comments block.
- Where will you find the Comments block that would’ve been added to your site by default?
- What are the differences between using a classic theme and a block theme?
Hi, and welcome to Learn WordPress. Today we’re going to take a closer look at how post comments are displayed when you’re using a block theme. But before we make our way to the backend of our website, let’s see how comments display when people respond to a blog post. When I visit the front end of my website, I will click on one of my blog posts. When we go to the bottom of the post, we will notice three people have already responded by adding their comments, Roger, Tina and Ross and below that, there is a section for more people to have their say.
Allowing comments on your site has many advantages. It allows you to deepen your relationships with readers and find out what readers are interested in. It also increases the likelihood of them subscribing to your newsletter or purchasing something in the future. Essentially, allowing comments can help you build a community around your blog. It is, of course, essential to manage comments effectively by using the built-in settings of WordPress under Discussions in your dashboard and installing an anti-spam plugin.
But for now, let’s make our way back to the dashboard to investigate the Comments block. But to do that, we need to have access to templates. So to make it clear, the Comments block is for templates, and usually forms part of your single post template and page template by default. There are two ways to access templates, via the Site Editor and the Template Editor.
Let’s first make our way to the Site Editor. Go to Appearance and click on Editor. This opens up the Site Editor where you’re able to manage your templates, template parts and also where you can customise the site-wide styles of your website. We are after the single template today. The single template displays the page structure for single posts. When we open up the list view, we will have a clearer picture of the current layout of single posts, and right at the bottom, we’ve got the Comments block. Have you ever wondered what will happen if you delete the Comments block? Well, all comments on all blog posts that have been assigned to this template will disappear on the front end of your website.
Let’s see this in action. Click on the three vertical dots and select Remove comments, and after saving our changes, we will make our way to the front end of our website to one of the posts that have been assigned to this template. And now, we will refresh the page. And when we do that, we will see that the comments have disappeared. But of course, I actually don’t want to do this so I’m going to undo my changes. Click Save again. Return to the post. Refresh. And now we will notice the comments are back.
The second way we access templates is via the Template Editor. If we are back in our dashboard, we can make our way to posts and open one of our existing posts. And in the sidebar settings, we’ll see that the default template is being used, which is the single post template, and when we click on Edit Template, it will take you into the Template Editing Mode. And here you are able to customise your single template just as when you were in the Site Editor. When we open the list view, we will see that the Comments block is part of a Group block. The one difference you will notice when you are in Template Editing Mode is that the content of your post and the post comments are visible.
Please remember, though, templates are used to create site structure and are not used to add or edit content. But when we go back to our post and click on the template, you can add a custom template. So once you’ve named it appropriately, you can click on Create. When you create a custom template, you, of course, need to add a new header and a new footer. But if you also want comments to be displayed on this post, you need to add a Comments block. So I’m going to insert a Comments block below the Post Content block, and once you add your Comments block, you will ensure, number one, that visitors can leave a comment and, number two, that all comments are displayed.
Just a quick note about displaying a comments area on a page. As you will remember, the Comments block is part of your template, and we can see this when we make our way to the Site Editor and select the page template. When we open up the list view, we will see that the Comments block is part of your template and not your page. So if you want a comments area to be visible on your page, you need to open your sidebar settings, and below Discussion, select Allow comments.
So if you have installed a block theme, be on the lookout for the Comments block and be careful not to delete it accidentally. Explore Learn WordPress for more tutorials and training material.
I am an Instructional Designer for the WordPress open-source project sponsored by Automattic. I am a strong supporter of the open-source movement. I have a background in education and content development. I am a husband, father, dreamer and lifelong learner.