Congratulations! Tell me where it is better to declare a function that uses the global variable Wp $posts to use this function in setup.php . In sage 9, it was enough to create a file and connect it to function.php. Tried by analogy, but it doesn’t work in sage 10
So you want to add a hook and use the $post
global inside, this should work the same in Sage 10 though. What code are you using? You can put the code to add the hook and its handler function in setup.php
of the theme.
Your screenshot of the setup.php
listing is the same as of function.php
, so it can’t be seen how the function is actually used. Are you calling it by \App\get_temlate_name_camel_case()
?
The function is called like this $test = get_template_name_camel_case();
The most interesting fact is that the code editor sees this function, but the template does not want to work with it, and unfortunately, I cannot understand why.
Depending on the code in setup.php, you might need to require helpers before setup.
If that doesnt work, please show us the relevant code of setup.php (preferrably pasted instead of screenshotted).
It looks completely stock as it comes out of the box with Sage 10
The error message that you posted has nothing to do with trying to access the global $post
but tells you that the function get_temlate_name_camel_case()
does not exist when you are calling it in setup.php. Hence why both @strarsis and I have been asking to see the code of setup.php (which you seem to have missed to include in your previous screenshots) where you are calling the missing function.
Afaik, get_temlate_name_camel_case()
is not a stock Sage function so neither is any call to it.