Support

Account

Home Forums ACF PRO How to add custom class to admin_body_class based on ACF field data? Reply To: How to add custom class to admin_body_class based on ACF field data?

  • You are attempting to access to value of the field outside of “The Loop”. This means that ACF will not know what post to get the value from and you must supply that.

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