将#id 添加到 the_permalink()
Adding #id to the_permalink()
我似乎想不出这方面的代码。我目前在 functions.php 我的儿童主题中。
我正在尝试在 post 的评论部分添加一张图片 link。我已经有一个 link 指向 post 本身的按钮。
代码看起来像
<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>
当我尝试时,它就是不显示。如果我使用 <a href="#reply-title"></a>
它会出现,但当然不会 link 到 post,然后到 id。
我尝试了不同的变体,甚至使用 echo 来让它工作。
但我似乎无法弄清楚如何将#reply-title 添加到当前的 permalink 中。
它在 functions.php 中的原因是因为我需要将此 link 添加到每个 post.
的底部
尝试:
<a href="<?php echo get_the_permalink(); ?>#reply-title">
如果我理解正确,您需要这个:
<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>
我似乎想不出这方面的代码。我目前在 functions.php 我的儿童主题中。
我正在尝试在 post 的评论部分添加一张图片 link。我已经有一个 link 指向 post 本身的按钮。
代码看起来像
<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>
当我尝试时,它就是不显示。如果我使用 <a href="#reply-title"></a>
它会出现,但当然不会 link 到 post,然后到 id。
我尝试了不同的变体,甚至使用 echo 来让它工作。
但我似乎无法弄清楚如何将#reply-title 添加到当前的 permalink 中。
它在 functions.php 中的原因是因为我需要将此 link 添加到每个 post.
的底部尝试:
<a href="<?php echo get_the_permalink(); ?>#reply-title">
如果我理解正确,您需要这个:
<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>