Reputation: 15
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?
Upvotes: 0
Views: 369
Reputation: 488
You should use is_category()
function to add display condition in archive.php
:
if(is_category(CATEGORY_ID)) {
$fields_type = acf_get_field(‘type’);
print_r($fields_type);
}
Note: Replace CATEGORY_ID with your category ID or slug that you want this field can displayed.
Upvotes: 2