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 http://www.example.com/taxonomy_name/page_slug.
I also tried :
global $post; $post->id;
It is also giving ID of first record from database.
How to get the ID of page?
Answer
I think this is what you want:
$qobj = get_queried_object();
var_dump($qobj->term_id);
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..
Attribution
Source : Link , Question Author : mahender singh , Answer Author : s_ha_dum