WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] calling post_name to use as a variable

[Resolved] calling post_name to use as a variable

  • 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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;

    Thank you!

    -Sara

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] calling post_name to use as a variable’ is closed to new replies.