Support

Account

Home Forums General Issues ACF field is displayed in all categories

Solved

ACF field is displayed in all categories

  • In the field group settings, I specified to display the field in only one category. That is, in the rule, I selected Category equal to the corresponding category from the list.

    For the test in the arhive.php template, I output:
    $fields_type = acf_get_field(‘type’);
    print_r($fields_type);

    This array is displayed in all categories. How can I make it so that the fields are displayed only in those frontend categories that I have selected in the admin panel settings?

  • You need to test to see if the field has a value, if it does not then it is not used.

    
    if (get_field('type')) {
      // field is used and has a value
    }
    
  • Maybe I’m doing something wrong, because this condition does not work in any frontend category. And the get_field(‘type’) function always returns an empty value.
    Tell me please, what could be the problem?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.