2 ways, we have to get current post id in wordpress
First way:
global $posts;
$current_post_id = $posts->ID;
Second way:
global $wp_query;
$current_post_id = $wp_query->post->ID;
First way:
global $posts;
$current_post_id = $posts->ID;
Second way:
global $wp_query;
$current_post_id = $wp_query->post->ID;
0 comments:
Post a Comment