Twain
Twain

Reputation: 409

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.

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.

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.

the reason it is in the functions.php is because i needed to add this link to the bottom of every post.

Upvotes: 0

Views: 450

Answers (2)

Ferrmolina
Ferrmolina

Reputation: 2771

Try:

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

Upvotes: 1

wrkman
wrkman

Reputation: 100

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>

Upvotes: 0

Related Questions