Under each comment there is a link called ‘Reply’. I want to add a class to this link. It’s default class is comment-reply-link
. How can I do so? I am creating my own theme and I don’t want to manually edit files inside the wp-includes directory.
Leave a Reply
You must be logged in to post a comment.
In your comments.php template file use
wp_list_comments
and set the parametercallback
to your defined function that will generate the template. Inside the function you can style the comment reply link.wp_list_comments codex
Further reading on comment display
I know this is quite an old post and maybe this could help someone.
You can replace the class of an element using add_filter();
Here’s an example:
With this you should be able to replace the class in your themes.
I hope this can be of any help for someone 🙂
Quite old post, but while searching I came here, maybe someone else will find it useful.
The only solution I found is to completely rebuilt the button that
comment_reply_link
returns.I first made two vars reconstructing
href
andonclick
attributes for the reply button:And then output the whole reply block, adding your custom classes:
This might not be an elegant solution but it gets the job done. Do it with jQuery. Basically find the element and add the class you need. WordPress totally didn’t make this easy to customize:
Also something to double check (as I overlooked this for about half an hour)…
Make sure under: Settings > Discussion
This checkbox is checked:
Otherwise the reply button will not show up at all