How to Customize Comment Display and Post Meta in Twenty Seventeen
Content
Many users of the Twenty Seventeen theme want to adjust how comments, post meta information (like author names and comment counts), and other elements are displayed on their homepage and blog listings. This is a common request because the default theme behavior doesn't always fit every site's design or user engagement goals. Readers might miss the comment section if it's buried below other post elements, or you might want to showcase engagement metrics like comment counts directly on your front page.
Why This Happens
The Twenty Seventeen theme is designed with a specific structure for single posts and archive pages (like the homepage blog listing). By default, the full comment form and existing comments are typically only loaded on the single post page. Similarly, certain post meta information, like the author's name, is often hidden on archive pages to maintain a cleaner layout. This structure is built directly into the theme's template files, such as content.php and template-tags.php.
Common Solutions
1. Moving Comment Location and Adding Comment Links
A frequent issue is that plugins for related posts, sharing, or statistics appear below the post content but above the comments section. This can make comments less visible. To change this order, you need to understand WordPress's template hierarchy and action hooks.
Important First Step: Before making any code changes, always create a child theme. This prevents your modifications from being overwritten during theme updates.
The placement of comments is controlled in the single.php template file. You would need to create a copy of this file in your child theme and adjust the order in which template parts are called. However, this often requires moving the comments_template() function call to a different location within the file, which can be complex and may conflict with plugin output.
For a simpler solution that doesn't require deep coding, many users find success with plugins designed to reorder content elements. Searching the WordPress plugin repository for "reorder content" or "rearrange posts" can yield tools that provide a user interface for this task.
To add a comment link or count on the blog listing page (like your homepage), you can modify the post meta section. The code that controls this is often found in the content.php file of your child theme. Look for the twentyseventeen_time_link() function or the div with class entry-meta. You can add the following function to output a link to the comments:
comments_popup_link( 'Leave a comment', '1 Comment', '% Comments' );
2. Displaying Author Name and Comment Count on Homepage
By default, Twenty Seventeen uses a conditional statement to show the full post meta (including author) only on single posts (is_single()). To display the author on archive pages, you need to override this in your child theme's content.php file.
Find the lines that look similar to this:
echo '<div class="entry-meta">';
if ( is_single() ) {
twentyseventeen_posted_on();
} else {
echo twentyseventeen_time_link();
twentyseventeen_edit_link();
};
echo '</div><!-- .entry-meta -->';
You can modify it to always show the full post meta, which includes the author:
echo '<div class="entry-meta">';
twentyseventeen_posted_on(); // This function outputs author and date
twentyseventeen_edit_link();
echo '</div><!-- .entry-meta -->';
To add a comment count next to the date on archive pages, you could modify the twentyseventeen_time_link() function in your child theme's `functions.php` file. This is a more advanced modification and was a common solution discussed in support threads. However, be aware that this function may change during theme updates, which could break your customization.
3. Hiding Zero Comment Counts
If you've added comment counts but want to hide the "0" when a post has no comments, you can use simple CSS. Add the following code to the Additional CSS section in the WordPress Customizer (Appearance > Customize > Additional CSS):
.entry-meta .comments-link {
display: none;
}
To only hide the zero but show counts of one or more, you would need a more advanced PHP solution to conditionally output the HTML.
4. Displaying Full Comments on the Homepage
Showing the actual comment list and comment form on your homepage under each post is a significant structural change. The theme is not built for this by default. This would typically require creating a custom page template that uses a loop to display posts and then manually calls comments_template() for each post. This is an advanced development task that may have performance implications and is generally not recommended without extensive testing.
Important Considerations
- Child Theme: Always use a child theme for any code modifications. This is the most crucial best practice for maintaining your changes.
- Theme Updates: Be aware that the underlying code of the Twenty Seventeen theme can change. A solution that works today might break after a future update, so it's good to test after any update.
- Plugin Alternatives: For many of these changes, especially reordering content or adding new meta fields, using a dedicated plugin can be a more sustainable and easier-to-manage solution than custom code.
While the Twenty Seventeen theme offers a solid foundation, customizing its output is a common need. By carefully using child themes and understanding the template files, you can achieve the layout that best suits your website's audience.
Related Support Threads Support
-
Move comments directly below post content?https://wordpress.org/support/topic/move-comments-directly-below-post-content/
-
Reply Line on Main Blog Pagehttps://wordpress.org/support/topic/reply-line-on-main-blog-page/
-
Adding a comment box to Homehttps://wordpress.org/support/topic/adding-a-comment-box-to-home/
-
Show Author on Homepage Blog Sectionhttps://wordpress.org/support/topic/show-author-on-homepage-blog-section/
-
Hide comments-count 0 from start pagehttps://wordpress.org/support/topic/hide-comments-count-0-from-start-page/
-
Adding hit counter to front page summarieshttps://wordpress.org/support/topic/adding-hit-counter-to-front-page-summaries/
-
front page – blog section – show blogs from specified category onlyhttps://wordpress.org/support/topic/front-page-blog-section-show-blogs-from-specified-category-only/
-
How to set comments boxhttps://wordpress.org/support/topic/how-to-set-comments-box/
-
How to display byline on Posts Page?https://wordpress.org/support/topic/how-to-display-byline-on-posts-page/
-
Show comments on Homepagehttps://wordpress.org/support/topic/show-comments-on-homepage-3/
-
Link for making comments missing on blogpagehttps://wordpress.org/support/topic/link-for-making-comments-missing-on-blogpage/
-
How can i add the number of comments for each post on front page?https://wordpress.org/support/topic/how-can-i-add-the-number-of-comments-for-each-post-on-front-page/
-
Add “Last Updated on” to postshttps://wordpress.org/support/topic/add-last-updated-on-to-posts/
-
Show Author on Front One Pagehttps://wordpress.org/support/topic/show-author-on-front-one-page/
-
Possible BUG on load comments logic.https://wordpress.org/support/topic/possible-bug-on-load-comments-logic-2/
-
Possible BUG on load comments logic.https://wordpress.org/support/topic/possible-bug-on-load-comments-logic/
-
Comment Count Per Post Broken After Theme Update?https://wordpress.org/support/topic/comment-count-per-post-broken-after-theme-update/
-
Limit Number of Blog Posts Displayed on Front Homepagehttps://wordpress.org/support/topic/limit-number-of-blog-posts-displayed-on-front-homepage/