WordPress notes: Comments

I have been fooling around WordPress for a long time but today I found out that either it wasn’t long enough or that my memory doesn’t serve me as well as I have thought. But it just might be that I was focused on other things in life. Today I finished coding theme for my website and I wasn’t happy with default look of comments section. I wanted to do more than good enough.

Basic command to create comments list is wp_list_comments() and in underscores theme there’s a default implementation as:

It works quite well but I dislike how WordPress generates comments by default:

But I prefer to have a different structure:

To achieve this I had to create a new parameter for wp_list_comments() 'callback' => 'sarahgebauer_comments' and then I had to create this function in functions.php file. Finally it looks like this in comments.php:

And in functions.php:

With this knowledge I have a higher flexibility when creating comment section. I hope that you have found this snippet helpful.