I’m struggling with wordpress templates. In one of my theme templates I have the following lines
<?php
echo get_the_ID(); // displays nothing
echo get_the_title(); // displays "Hello World! this is title"
?>
Why does the get_the_ID() return nothing ? I want the page id of the current page I’m on.
This works within the loop:
Outside of the loop:
if you are using wp_query just add this