getting id of page

I am using taxonomy.php to display records from database. The function get_the_ID() in taxonomy.php gives the ID of first record from database.

My URL is

I also tried :

global $post;

It is also giving ID of first record from database.

How to get the ID of page?


I think this is what you want:

$qobj = get_queried_object();

get_queried_object will get information about the current page. That information varies by type and content for different pages but on a taxonomy page it will give you a stdClass object with taxonomy data related to that page..

Source : Link , Question Author : mahender singh , Answer Author : s_ha_dum

Leave a Comment