Video Tutorial Comments


In this chapter we will see how to manage the display of comments. As for the menu, WordPress has a very strong opinion on the HTML structure and it will be better to stick to this structure to avoid maximum work. It is however possible to customize things in depth using hook and Walker.

Show Comments

To display the comments, simply use the function comments_template ().


This function will search for a file comments.php and use it to manage the display. If you don't have this file in your theme, a default template will be used.

For this file you can take inspiration from the code of themes proposed by default (twentytwenty for example) but we will retain 3 functions:

  • comment_form (), displays the form. It is possible to customize the appearance of the fields by plugging into filters like comment_form_default_fields.
  • wp_list_comments (), displays the list of comments. The personalization will be done through a personalized Walker which it will be possible to pass as a parameter in the arguments of the function.
  • paginate_comments_links (), manages the pagination of comments if the number of comments exceeds the limit set in the backoffice.