How To: Current Page or Post Slug in WordPress

To find the current page’s ID, post_title, or post_name (slug) in wordpress, use the code below:

$post_obj = $wp_query->get_queried_object();
$post_ID = $post_obj->ID;
$post_title = $post_obj->post_title;
$post_name = $post_obj->post_name;

Leave a Comment

*

Spam protection by WP Captcha-Free