I want to use get_the_ID() to get the custom fields for the page currently being viewed by the user. The problem is that get_the_ID() is not working in the sidebar.php. It only works inside the loop.
I’m writing some PHP code in my sidebar.php that requires me to know the id of the current post.
How am I to get?
- The topic ‘How to use get_the_ID() in sidebar?’ is closed to new replies.