Support

Account

Home Forums General Issues Help! True / False to include or exclude featured image in wordpress. Reply To: Help! True / False to include or exclude featured image in wordpress.

  • Because in functions.php, before the loop, ACF does not know what post to get the value from. Missed that earlier.

    You need to supply ACF with the post ID. This needs to happen inside “the loop” or you need to figure out the post ID that will be loaded, if it is a single post.

    for example

    
    $queried_object = get_queried_object();
    if (is_a($queried_object, 'WP_Post')) {
      if (get_field('', $queried_object->ID)) {
        ....
      }
    }
    

    Even using this it may not work until after ‘init’ and you should never call an acf function before ‘acf/init’ the reason for this is that it causes premature initialization of ACF that can cause other issues. I would suggest trying to to this on and the WP ‘init’ action with a high priority.