By default, the comment link in WordPress will jump us to a div tag called “#respond”, but that only makes sense if using the default WordPress comment system.
If we are not using the default WordPress comment system (maybe something like Disqus, which is what I use here), then clicking on that “Leave a Reply” or “Leave a Comment” link won’t take you anywhere. If you are using a different comment system, there is a likelihood that the ID tag they use to target their comment box is different.
For my example, Disqus uses an ID tag called
"disqus_thread". I wanted my readers to be able to click the link and be automatically taken to the Disqus comment area, so I had to figure out a way to make this happen.
Fortunately for us, WordPress provides us with a filter to do so: get_comments_link. For most people, you will want the comment link in WordPress to remain linked to the current post. I’ve highlighted it in the code, but you will likely just want to change the ID hash to reference the proper element for your comment system.
Just drop this code into your theme’s
functions.php file and you can be on your way!
And that’s it folks! You’ve now successfully changed your comment link in WordPress!