Seems the variable
motd does not load anything so second check fails as well.
<?php // new acf block field to be added $motd = get_field('motd'); var_dump($motd); // NULL $molecule_month = get_the_terms($motd->ID , 'molecules_of_the_month' ); var_dump($molecule_month); // warning trying to read property ID on NULL
so results show
NULL Warning: Attempt to read property “ID” on null in /Users/jasper/code/site/wp-content/themes/theme/blocks/random-molecule/block.php on line 24 bool(false)
And that gets me back to issue with ACF block. I have the base on just loading a molecule on selection and a new one
<?php acf_register_block_type( array( 'name' => 'molecule-of-the-day', 'title' => __( 'Molecule of the day', 'theme' ), 'render_template' => 'blocks/molecule-of-the-day/block.php', 'category' => 'theme', 'icon' => 'image-filter', 'mode' => 'auto', 'keywords' => array( 'molecule' ) )); acf_register_block_type( array( 'name' => 'random-molecule', 'title' => __( 'Random Molecule', 'theme' ), 'render_template' => 'blocks/random-molecule/block.php', 'category' => 'theme', 'icon' => 'image-filter', 'mode' => 'auto', 'keywords' => array( 'molecule' ) ));
In the first block
$motd = get_field('motd'); works just fine. In my new one under construction it does not. Why is that? Am I doing something now I should not or that is not possible? Just do not understand this.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
2022 was a big year for Advanced Custom Fields, with more capabilities, a new generation of ACF Blocks, a refreshed UI, and a new home. Our year in review post looks at advancements we’ve made and offers a glimpse of the future.— Advanced Custom Fields (@wp_acf) January 6, 2023
© 2023 Advanced Custom Fields.