Home › Forums › General Issues › Add category name to body classes › Reply To: Add category name to body classes
I thought I should add more details.
Here are my investigations :
There is a screen capture of my post edition page attached.
I found a json file in my theme that seems to deal with categories in an ACF-jon folder :
{
"key": "group_5ac5d1e87ab94",
"title": "Categorie",
"fields": [
{
"key": "field_5ad704be7333f",
"label": "Afficher la catégorie courante",
"name": "afficher_les_articles_dans_la_page_categorie",
"type": "true_false",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"message": "",
"default_value": 1,
"ui": 1,
"ui_on_text": "",
"ui_off_text": ""
}
],
"location": [
[
{
"param": "taxonomy",
"operator": "==",
"value": "categorie"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": 1,
"description": "",
"modified": 1530175641
}
And finally that’s what I tried to add in function.php with no success :
add_filter('body_class', 'add_acf_body_class');
function add_acf_body_class($class) {
$value = get_field('afficher_les_articles_dans_la_page_categorie', false, false);
$class[] = $value;
return $class;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚀 We’re excited to announce we've released Composer support for installing ACF PRO.
— Advanced Custom Fields (@wp_acf) January 31, 2023
🎉 #ComposerPHP fans rejoice!
✨ Please see the release post for all the details and full instructions. https://t.co/ebEfp61nlR
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.