I have a variable, created in page.php, and would like to pass this to a function in functions.php.


  • make it global var in page.php ( $GLOBALS $my_var = 'blah blah'; )and you can call it in you functions.php ( $GLOBALS $my_var ) ( page.php and functions.php ) both tamplate you have yo make it global – Mohamed Rihan Jan 18 '16 at 13:18
  • 1
    Yes, it is possible. If the function exists in functions.php then your page.php will have access when it gets loaded -- assuming they are the same theme. – jgraup Jan 18 '16 at 16:44

I may be dramatically wrong, but I believe not: theme's PHP files are executed after functions.php. Check the chart in this answer.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.