Getting the the permalink into a variable ?
-
OK i’m not expecting a great deal of help considering all my other posts have remained unanswered but here goes anyway ??
OK i’m coding a routine to go into template.php and everything is working great.
However how do i get the real life permalink of the post.
I’ve tried using
$post->guid but that’s storing some weird old paths (i.e. https://localhost as well as other variants). Ironically however wordpress is displaying, using the the_permalink () function in normal templates, just right.
So i tried (within my loop) to capture that as a string using
<strong>ob_start(); the_permalink (); $link= ob_get_contents(); ob_end_clean();</strong>
But although that works in say the home.php template it refuses to work in my templates.php under my function.
I have every other variable i need working in that function apart from the permalink. Anyone any ideas how i can get it to read that into a variable so i can output it into a a href within my function ?
I even looked (and failed) to find the the_permalink () function in the wordpress php files.
I really need help on this one guys.
- The topic ‘Getting the the permalink into a variable ?’ is closed to new replies.