loop and return slug that matches post id laravel code example Example: get current page slug $slug = get_queried_object()->post_name;