Populate acf-field, depending on block name

You are calling get_post() using null. Try to retrieve the post individually. Use get_post(get_the_ID()) to get the post content. $post = get_post(get_the_ID()); if ( has_blocks( $post->post_content ) ) { $blocks = parse_blocks( $post->post_content ); if ( $blocks[0][‘blockName’] === ‘acf/full-width-talker’ ) { } }

The function called on the wp head hook becomes null

As an alternative you could try declaring it with $GLOBALS[‘a3’] in file2 to make sure it becomes a global: $GLOBALS[‘a3′] = Sample_Class::instance(); I’d guess the current $a3 declaration in file2’s top level scope doesn’t count as global because it gets inluded inside the test_loaded() scope. From the ‘include’ docs (which cover require and require_once too): … Read more

Store a value in global scope after init hook is fired

So after consulting on Facebook Advanced WordPress group, the advice was to create an object with setters and getters instead of using the declaring and getting variables in the global scope as shown in the code below: class MyPlugin { public $current_post_types; public function __construct() { add_filter(‘init’, array($this, ‘get_variables’)); } public function get_variables() { $this->current_post_types … Read more