0

I want to be able to style the comments section to work with the theme I am building. I do not have a comments.php file in the website however when I include:

<?php if ( comments_open() || get_comments_number() ) :
            comments_template();
        endif;

?>

I get a full comments section under my post, being able to add and view comments and commenters info. I thought that when I include the above if statement it was supposed to pull the info from the comments.php file that included all of my html with it.

I now don't know where to view the CSS that is attached to the comment form, except in the Google 'Inspect' section for developers, so that I can alter it.

I looked in the twentynineteen theme and it has my code as well as a very complicated comments.php file. I can't claim to fully understand the comments.php file but I'm confused about how I am getting an output of a comment form and its replies without having to have a comments.php file.

What am I missing? Can someone help clear this up for me?

1

If in the root of the folder of your theme there is no file "comments.php". Than comments_template () include the file from the path "/wp-includes/theme-compat/comments.php".
To make changes in that file you can copy "comments.php" from this folder to the root of your theme. And then change as you like.

  • Ah that clears it up. Thank you :) – Niall Jun 28 at 18:38
  • Wordpress has a fallback comments template integrated in it's core (since it is "blogsystem"). When there is no comment template, wp will use this as a default fallback. – user3135691 Jun 28 at 18:43
  • I have added both the comment.php and comment-template.php to my root folder and attempted to make changes to the form, such as changing the submit button value, in the comment-template.php but my changes are not working. Any idea why? Sldo the comment_form() is the only function that shows the html that is added in, comment_template() does not. – Niall Jun 28 at 20:06
  • @Niall You can change this form through its arguments. Also you can use actions and filters hooks, check there and this – Rimarx Jun 29 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.