i have to get page ID in wordpress throught php?
You need to use the_ID() inside the loop.
Presuming to a style, it's as easy as this.
There's a worldwide variable "
$post" which consists of the attached information from the current publish / page, and it is really an item. You have access to information just like you access variables from an item. Make sure to ensure that it stays within the while loop.
For instance, confider the next:-
<?php if (have_posts()) : ?> <?php while (have_posts()): the_post(); global $post; $idPagePost = $post->ID; endwhile; ?> <?php endif; ?>
The variable "$idPagePost" will retain the ID from the current page / publish.
Hope it will help.
global $wp_query; $id = $wp_query->post->ID; // OR: $id = $wp_query->queried_object_id;
This works any place in your styles or plug ins, as lengthy in fact after WordPress is loaded.