Globals aren’t passed into functions. You have to declare them.
Change this:
function test() {
return $post->ID; //or echo $post->ID;
}
…to this:
function test() {
global $post;
return $post->ID; //or echo $post->ID;
}
Globals aren’t passed into functions. You have to declare them.
Change this:
function test() {
return $post->ID; //or echo $post->ID;
}
…to this:
function test() {
global $post;
return $post->ID; //or echo $post->ID;
}