I need to get the current page id in WordPress plugin page outside the loop. And the code I wrote for getting current page id is in my plugin page.
page id
You can get ID of the post in current page outside the loop using the technique below:
ID
global $wp_query; $post_id = $wp_query->post->ID; $post = get_post( $post_id ); $slug = $post->post_name;