Support » Plugins » I need the post slug

  • Resolved Leovenous

    (@leovenous)


    Is the slug queried in the post function so that I can jet it into a link URL as a $ variable?

    What I need to do is make a post link to a page that happens to have it’s slug. I’m thinking this is the easiest way to link a dynamic post to pages dynamically.

    So I am picturing something like <?php the_slug(); ?>

    I also was trying to find that cool snippet of PHP that will display all the variables in a session. I wanted to use it to see what WP has floating out there. Anyone know it?

Viewing 7 replies - 1 through 7 (of 7 total)
  • whooami

    (@whooami)

    Member

    you would be better served to upgrade your current 2.0 install to 2.0.11

    In your curiosity, maybe you’ve missed all this:

    http://www.google.com/search?hl=en&q=wordpress+2.0+exploit&btnG=Google+Search

    And if you think wordpress blogs arent getting hacked these days, here you go:

    http://wordpress.org/search/hacked?forums=1

    There was one reported just yesterday, and I ‘found” one this morning as well where the user wasnt even aware.

    Ummm… I don’t know what you’re getting at.

    Maybe I’m not being as clear as I could be. Normally when a post is linked it uses the the_permalink tag in an <a href> to link to an archives page. I want it to link to a template page. How to do that, my idea was to use the slug to make the link.

    So I am either asking if there is a variable I can grab the slug with, or if there is a better way to accomplish what I am after.

    I figured it out, there is a function (get_post) that let me pick any part out of it, so I ended up with this code within my loop:

    <?php // Get the Slug to use as the link
      $extrapostdata = get_post(the_ID(), ARRAY_A);
      $slug = $extrapostdata['post_name'];
     ?>
    <h2><a href="/<?php echo($slug); ?>"><?php the_title(); ?></a></h2>

    I still have to figure out why it is displaying the post number on the page.

    Anyway, thank ya’ll for your wonderful, helpful, expert advice.

    anyone ever figure out how to remove the post #?

    Cheers Leovenous, that chunk of code was exactly what I’ve just spent the last 20 minutes searching for… nice one!

    And for anyone else looking for the same functionality, I can confirm that this method holds good for WP 2.5.1.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘I need the post slug’ is closed to new replies.