I'm getting the PHP error "call to undefined function get_field" once in awhile, but not consistently.
Advanced Custom Fields says to prevent this, wrap my function in acf/init to be sure ACF is fully loaded before get_field is called.
What I have is below, but the problem is now that the output from the shortcode bulletins does not show on the front end.
I'm using ACF Pro 6.4.2 and that has the feature of adding Options Pages from the GUI admin, and I don't have to init options pages separately in functions.php
https://www.advancedcustomfields.com/resources/options-page/
In my code below:
Am I using acf/init correctly in functions.php?
Are options fields handled differently by acf/init?
What about using the shortcode? Is that a problem?
Is using a global i.e., global $bulletin_text a bad idea?
add_action('acf/init', function() {
$bulletin_text = get_field('bulletin_text', 'option');
function show_shortcode_bulletin(){
global $bulletin_text;
return $bulletin_text;
}
add_shortcode('bulletins', 'show_shortcode_bulletin');
});