To view comments on a video, scroll down the video's page. Replies are threaded to make it easy to follow conversations. All comments on YouTube are public and anyone can reply to a comment that you post. If you can't find a comment after you get a notification, it's possible that the comment has already been removed. Comments can be added to an entire dashboard, to individual visuals on a dashboard, to a report page, to a paginated report, and to individual visuals on a report page. Add a general comment or add a comment targeted at specific colleagues.
- Breaking down the comments.php
WordPress displays comments in your theme based on the settings and code in the
comments.php file within your WordPress theme.
Simple comments loop Simple comments loop
comments.php template contains all the logic needed to pull comments out of the database and display them in your theme.
Before we explore the template file you’ll want to know how to pull in the partial template file on the appropriate pages such as
single.php. You’ll wrap the comment template tag in a conditional statement so comments.php is only pulled in if it makes sense to do.
Another Comments.php Example Another Comments.php Example
Here’s an example of the
comments.php template included with the Twenty Thirteen theme:
Breaking down the comments.php Breaking down the comments.php
comments.php can be broken down to the below parts for better understanding.
- Comments are closed message.
Template Header Template Header
This template begins by identifying the template.
Next, there’s a test to see if the post is password protected and, if so, it stops processing the template.
Finally, there’s a test to see if there are comments associated with this post.
Prints out the header that appears above the comments.
Comment Listing Comment Listing
The following snippet creates an ordered listing of comments using the wp_list_comments() function.
Comment Pagination Comment Pagination
Checks to see if there are enough comments to merit adding comment navigation and, if so, create comment navigation.
If comments aren’t open, displays a line indicating that they’re closed.
The End The End
This section ends the comments loop, includes the comment form, and closes the comment wrapper.
If you have a lot of comments (which makes your page long), then there are a number of potential benefits to paginating your comments. Pagination helps improve page load speed, especially on mobile devices.
Enabling comments pagination is done in two steps.
- Enable paged comments within WordPress by going to Settings > Discussion , and checking the box “Break comments into pages” . You can enter any number for the “top level comments per page”.
- Open your
comments.phptemplate file and add the following line where you want the comment pagination to appear.
Alternative Comment Template Alternative Comment Template
On some occasions you may want display your comments differently within your theme. For this you would build an alternate file (ex. Willie burton the initials game on. short-comments.php) and call it as follows:
The path to the file used for an alternative comments template should be relative to the current theme root directory, and include any subfolders. So if the custom comments template is in a folder inside the theme, it may look like this when called:
Function Reference Function Reference
Facebook Page Without Comments
- wp_list_comments() : Displays all comments for a post or Page based on a variety of parameters including ones set in the administration area.
- comment_form() : This tag outputs a complete commenting form for use within a template.
- comments_template() : Load the comment template specified in first argument
- paginate_comments_links() : Create pagination links for the comments on the current post.
- get_comments() : Retrieve the comments with possible use of arguments
- get_approved_comments() : Retrieve the approved comments for post id provided.