简体   繁体   English

将#id添加到the_permalink()

[英]Adding #id to the_permalink()

I cant seem to figure out the code for this. 我似乎无法找出代码。 im currently in the functions.php of my child theme. 我目前在我的孩子主题的functions.php中。

i'm trying to have an image link to the comments section of the post. 我试图有一个图像链接到帖子的评论部分。 I already have a button that links to the post itself. 我已经有一个链接到帖子本身的按钮。

the code looks like 代码看起来像

<a href="<?php the_permalink(); #reply-title ?>">
<img src="http://trueidconference.com/wowministriesblogs/wp-content/images/JOINimg.png" alt="Mountain View" style="margin-left:12px;"></a>

when I try it, it just doesn't show up. 当我尝试时,它没有显示。 if I use <a href="#reply-title"></a> it shows up, but of course doesn't link to the post, then to the id. 如果我使用<a href="#reply-title"></a>它会显示,但当然不会链接到帖子,而是链接到id。

I have tried different variations even using echo to get it to work. 我什至尝试使用回声使它工作的各种变化。

But I just cant seem to figure out how to add #reply-title to whatever the current permalink is. 但是我似乎无法弄清楚如何将#reply-title添加到当前的永久链接中。

the reason it is in the functions.php is because i needed to add this link to the bottom of every post. 它在functions.php中的原因是因为我需要将此链接添加到每个帖子的底部。

尝试:

<a href="<?php echo get_the_permalink(); ?>#reply-title">

If I understand correct you need this: 如果我理解正确,那么您需要这样做:

<a href="<?php the_permalink(); ?>/#reply-title">
<img src="http://trueidconference.com/wowministriesblogs/wp-content/images/JOINimg.png" alt="Mountain View" style="margin-left:12px;">
</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM