I have a page with a shortcode that uses get_the_ID(). The shortcode displays custom fields from the current page.

When I include that page within another page, get_the_ID() returns the ID of the second page, not the original page where the shortcode is.

My question is: inside the shortcode, is there a way to get the ID of the page where the shortcode is included?

  • 3
    What does "include that page within another page" mean, exactly? – s_ha_dum Sep 20 '13 at 19:04
  • Thanks for the reply, and sorry it took me a while to see this. I include the page with the shortcode into another page, by using another shortcode. Currently, the first one is getting the ID of the second page where it's being displayed. It's been a while, I think I solved this whole issue by using a global variable. – Lio Eters Oct 3 '13 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.