Past the current post permalink to a variable

This code is good for use on any page, inside or outside of the loop and in custom queries:

<?php $myExcerptLink = get_permalink($post->ID); ?>

This is generally how I would use it to output a link:

	$myExcerpt = get_the_excerpt();
	//$myExcerptLink = the_permalink();
	$myExcerptLink = get_permalink($post->ID);
	if ($myExcerpt != '') {
		// Some string manipulation performed
	echo $myExcerpt; echo "<a href="$myExcerptLink">Read more.</a>"; // Outputs the processed value to the page


There are no revisions for this post.

Tags: ,

No comments yet.

Leave a Reply