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.
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.
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
This topic has been closed to new replies.