I am using a WooCommerce plugin for WordPress. Now in a file page.php I am trying to get the current opened page id via $post->ID
and the_id()
but all I am getting is the product ID and not the current page ID. Probably because WooCommerce overwrites the loop ?
What can I do ?
It might be too late, but i was trying to get the same result as you and this below worked pretty well for me:
Hope this will help you.
if you are trying to get the particular page id. Try with this.
This worked fine for me
global $post;$post->ID;
orglobal $wp_query;$wp_query->post->ID;
don’t work with woocommerce. You can get all the id’s of woocommerce page hereYou can try this, inspired by woocommerce_product_archive_description
I’m using this for my page.php file.
put this line above your code or at starting of script.
now you can use
$post->ID;
thanks
Had the same problem found a solution here
The code I used on my shop page was:
Basically replace the
shop
value with whatever woocommerce page you are trying to get.More documentation on the function and some other helpful functions can be found here