I want to do some (sometimes really complex) stuff on my pages based on pages/posts IDs', Settings API, etc.
Now I've all my functions written directly within page.php file, but I don't want it to leave it this way - it's really messy and it's hard to control everything. I'd love to have separate files for each function and load them from there. But there's a huge issue:
functions.php
function test() {
return $post->ID; //or echo $post->ID;
}
page.php
<?php
test();
?>
Of course test() returns nothing.
Is there any way to overcome that, or my approach is stupid once again? If yes - how should I store my functions outside of core theme files?
$post
global? If so, you need to define it as global...