Echoing a permalink?

hello i have this;

echo'<h3 class="entry-title">'.get_the_title().'</h3>';

but how can i add a call for a permalink?
I tried
to split up the href tag such as

echo '<a href="' .the_permalink().'">click';

And a few other variants w/no success. Could i get some advice on this?
thx

Did you try closing the <a> tag?

yep

What exactly is the problem, then? If the_permalink() returns a proper URL it should work just fine…

it doesn’t, that is why i wrote the topic.
this

echo'<h3 class="entry-title">'.the_permalink().get_the_title().'</h3>';

will return the link & title. great. but it is not clickable.
Other attempts like

echo'<href="'.the_permalink().'"> click me</a>';

will return a string like

http://agileart.us/arachnohazard/characters/devon-douglas/ click me
which is not a link. It is just text on the page

In this case, you forgot to open the <a> tag. :wink: Try

echo  '<a href="' . the_permalink() . '">click me</a>';
2 Likes

Good catch i thought i had put it in. the click me does show, but so does the entire hyperlink.

You mean, as in your previous reply? From that line alone, this can’t be the case. Maybe you have echoed it somewhere before. What’s the preceding line, or the exact line you’ve actually written for that matter?

no…this is the code

'post_type'=>'characters',
'post_per_page'=>5,
'order_by'=>'rand'
);
$bookChars = new WP_Query($args);

	echo'<div id="bookChars" class="bookChars">';
	while ($bookChars->have_posts()):$bookChars->the_post();
		echo'<figure class="bookCharsImgs">';
		the_post_thumbnail('smallRatio');
		echo'</figure>';
		echo  '<a href="' . the_permalink() . '">click me</a>';
		echo'<h3 class="entry-title">'.get_the_title().'</h3>';
		echo'<aside class="bookCharsAsides">';
		the_excerpt();
		echo'</aside>';

	endwhile;
echo'</div>';
wp_reset_query();


Actually, your old faulty line

echo'<href="'.the_permalink().'"> click me</a>';

shouldn’t output

either, just “click me”. So if this is all your code,

the_post_thumbnail('smallRatio');

seems to return that URL. Otherwise I don’t know. Try it with a hard-coded link and thumbnail and you’ll see.

Yeah it’s weird. the click me actually goes no where. it stays on that page. it seems to bring back the hyperlink of the page it is on, even thought the code is correctly bringing back the thumbnail and excerpt.

Thank you though
D

ok in case this comes up in the future, this worked
echo "<a href='".get_permalink($post->ID)."'>Read More</a>";

Hahaha sorry I entirely missed that this topic was about WP! D’oh! :smiley:

hey no worries :smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.