douchensou6969 2013-08-28 12:29
浏览 136
已采纳

为每条评论添加超链接

Here is an image of my comment format: http://oi40.tinypic.com/8w07jt.jpg

The hyperlink to each individual comment is the date and time with the url in the format of, for example: /nottingham/#comment-184

After going through my comment templates I found that these two functions do the following,

get_comments_link : Retrieves the link to the current post comments

AND

comments_link: Displays the link to the current post comments

The problem is I have no idea where to include these functions so it creates a hyperlink to every comment within every comment. Once this link has been created I'd also like to assign a div to it so I can format it to be in the bottom right corner of each comment.

My final goal is to manipulate the link so rather than the comment link itself it will automatically work in the facebook.com/sharer.php which I feel I can do myself once I figure out the previous part. Essentially it will be a share on facebook button, but I have found no plugins which do this yet and thought describing it as a hyperlink would be an easier way to explain what I'm trying to do.

Elsewhere I've been told the following: but not sure how to implement this...

In functions.php I'd add a 'get_comments_link' filter to return the desired link, including the tag you need. Note that this is a filter, not a function. There is function with the same name, but it's part of WordPress itself. Use the filter to add a div to the existing link. Then style the new div to position it where you want it. I notice that the Photoria theme repositions the Reply link, which is coded at the bottom but displayed at the top. In the same way, your new will be coded at the top but displayed at the bottom. Also see add_filter in the Codex. Add the new div to $link before returning it. The new div will need a class attribute so that you can work with it in CSS to make it look the way you want.

I hope I've made the question clear, please ask if I haven't. Thanks in advance!

  • 写回答

2条回答 默认 最新

  • dougaojue8185 2013-08-30 15:13
    关注

    Finally answered it myself, the code used to display the comment link was:

    <a href="<?php echo esc_url ( get_comment_link( $comment->comment_ID ) ); ?>"><img src=""</a>
    

    Which was inserted in my comments template file within my comments body div which I then put into another div so I could format it itself to where I wanted it positioned.

    Currently in the process of making the link automatically share through the facebook sharer...

    Hope this helps anyone with the same problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作