WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] calling post_name to use as a variable (3 posts)

  1. scormeny
    Member
    Posted 7 years ago #

    I'm working on a site that is now at [redacted].com .

    We want to get the value of post_name from a query post loop, similar to the_ID. But so far, no luck.

    Please help! Thanks.

  2. maerk
    Member
    Posted 7 years ago #

    If you're wanting it for use in a theme, you could use this:

    $post_name = $wpdb->get_var(SELECT post_name FROM $wpdb->posts WHERE ID = $id);

    echo $post_name;

    But try the following first, since the code above might be unnecessary.

    echo $post->post_name;

  3. scormeny
    Member
    Posted 7 years ago #

    Thank you!

    -Sara

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags