WordPress Get the current post slug

Hi there, I have search the net and this person found a way to get the slug the easier way.

 

The common approach:

$post_obj = $wp_query->get_queried_object();
$post_ID = $post_obj->ID;
$post_title = $post_obj->post_title;
$post_slug = $post_obj->post_name;

His approach:

$slug = basename(get_permalink());

That's it. Just include it inside the_loop.
Source: http://www.joshstauffer.com/get-post-slug-in-wordpress/

 

6 thoughts on “WordPress Get the current post slug

  1. cash for survey

    If you want to make $10-$150/hour and up to $3500/month of your free time working at
    home part-time then this is the most important message you’re ever
    going to read.

    Here’s why:

    “Businesses need ME! They’re paying me money – CASH – to a
    36-year-old work-at-home mother to get my opinion.”

    http://www.cash-reward-surveys.info/surveys.html

    Guess what?

    They also need YOU!

    I’m not a marketing expert or a sales gal. In fact, I know very
    little about business. But I do know exactly what I like and what
    I don’t like. I know what products I would buy and what services
    I would use.

    Guess what? This is exactly what large companies are paying me
    for. They need to know what their average customer needs and
    wants. So these companies pay millions of dollars every month to
    the average person. In return, the average person, myself
    included, answers some questions and gives them their opinion.

    You’ve got to try this out. Just click on the link below and
    check it out yourself.

    http://www.cash-reward-surveys.info/surveys.html

  2. Pingback: webpage

  3. Pingback: 1000 payday loan

  4. Pingback: hier klicken

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.