How to create a link to jump to "Leave a comment" part?

I would like the create a link that point to the comment part. So when reader click on my link, it will scroll down to t

I would like the create a link that point to the comment part. So when reader click on my link, it will scroll down to the place that they can leave a reply.

I have read some tutorial which teach how to create tag #id for headings in a post. However, I don't know how to do this for the comment part.

Please help! Thank you so much!

I would like the create a link that point to the comment part. So when reader click on my link, it will scroll down to the place that they can leave a reply.

I have read some tutorial which teach how to create tag #id for headings in a post. However, I don't know how to do this for the comment part.

Please help! Thank you so much!

Share Improve this question asked Aug 5, 2016 at 9:03 Tai ChristianTai Christian 1251 silver badge4 bronze badges 2
  • Edit your template, add an anchor ID just before your comment form, link to it :-) – Andy Macaulay-Brook Commented Aug 5, 2016 at 9:07
  • 1 Thank you, but I need a little more details. @CoderSte has pointed it out. – Tai Christian Commented Aug 16, 2016 at 3:16
Add a comment  | 

3 Answers 3

Reset to default 5

The code below should be something similar to what you're looking for

Inside the loop template you use for listing blogs (like index.php) you need something like this

<a href="<?php the_permalink(); ?>/#respond"> <!-- The blog permalink with the anchor ID after -->
    <i class="fa fa-comments-o"></i> Leave a Comment
</a>

Inside your comments.php file you could have this

<?php if ('open' == $post->comment_status) : ?>

    <div id="respond"> <!-- This is the element we are pointing to -->
        <!-- Code for comments... -->
    </div>

<?php endif; // if you delete this the sky will fall on your head ?>

I found a simpler solution, based on CoderSte's. Delete the

<?php the_permalink(); ?>/

from the first block of code, and then put it where you desire. That's it. The comment form already has the "respond" id, so you won't need to add the second block of code.

Removing the permalink part will prevent the site from reloading. It will simply jump to the comment section, which is the desired behavior.

This is all I added to my site. Add your button image in the tag.

<a href="#respond"><img src="" alt="" width="100" height="100" /></a>

If you are inside the loop you can also use the comments_link() function to echo the link or get_comments_link() to return.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744799042a4594379.html

相关推荐

  • How to create a link to jump to &quot;Leave a comment&quot; part?

    I would like the create a link that point to the comment part. So when reader click on my link, it will scroll down to t

    2天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信