• Resolved dizzy100

    (@dizzy100)


    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dizzy100

    (@dizzy100)

    Glad to see all this support here ??

    Anyway i solved it today.

    Use the function get_permalink() and pass it the post ID.

    So

    <strong>get_permalink($post->ID)</strong>

    Put in a loop of your SQL query will output the correct permalink to the posts your calling.

    Thread Starter dizzy100

    (@dizzy100)

    oops that shouldn’t have been there.

    Just use

    get_permalink($post->ID)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Getting the the permalink into a variable ?’ is closed to new replies.