Getting the slug into a variable, how to echo that variable August 19, 2022 by Tarik Billa Try this: $post = get_post($post_id); $slug = $post->post_name;