If you are in the loop then the other answers will help you. If instead you are out of the loop (for example you are hooking on the `init` or `plugins_loaded` actions), you can resort to a PHP primitive like `parse_url()`: ``` $post_slug = basename( parse_url( $_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH ) ); ``` Please note that this approach only works on posts/pages at root level.