Support

Account

Home Forums Backend Issues (wp-admin) Post Object at random Reply To: Post Object at random

  • 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.