Title: [Plugin: Polylang] Set body class depending on language
Last modified: August 20, 2016

---

# [Plugin: Polylang] Set body class depending on language

 *  [namoras](https://wordpress.org/support/users/namoras/)
 * (@namoras)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-polylang-set-body-class-depending-on-language/)
 * I don’t know if this was discussed before (found nothing), but since I now spent
   a few ours on it, I probably want to know how I did it later on 😉 and other 
   might be interested, I put it here.
 * My theme (Suffusion) does the header image with CSS background-image:, so I needed
   a different class for each language to be able to CSS-define a different header
   image in each language. I now put the a class named [language-slug] into the 
   body tag using the body_class function of WordPress. I put the following in the
   functions.php of my theme child:
 *     ```
       add_filter('body_class', 'my_custom_body_class', 10, 2);
         function my_custom_body_class($classes) {
           $classes[] = get_bloginfo('language');
           return $classes;
         }
       ```
   
 * This adds the class name ‘de-DE’, ‘fr-FR’ or ‘it-IT’ to the class list of the
   body tag, depending on the current language. I now can define the CSS background-
   image (and of cours other stuff) depending on the language, i.e.:
 *     ```
       body.de-DE #header-container {
         background-image: url(wp-content/themes/suffision-child/images/header-pic-de.png);
       }
   
       body.fr-FR #header-container {
         background-image: url(wp-content/themes/suffision-child/images/header-pic-fr.png);
       }
   
       body.it-IT #header-container {
         background-image: url(wp-content/themes/suffision-child/images/header-pic-it.png);
       }
       ```
   
 * [http://wordpress.org/extend/plugins/polylang/](http://wordpress.org/extend/plugins/polylang/)

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

 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-polylang-set-body-class-depending-on-language/#post-2496838)
 * Thank you for sharing !
 *  [marlora](https://wordpress.org/support/users/marlora/)
 * (@marlora)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-polylang-set-body-class-depending-on-language/#post-2497116)
 * Thank you, namoras!
    could please explain to a newbie how to add the language_slug
   using the body_class function? I have no clue of css and being able to change
   header according to the language is really important for my website. Thank you
   in advance!
 *  [ChowKaiDeng](https://wordpress.org/support/users/chowkaideng/)
 * (@chowkaideng)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-polylang-set-body-class-depending-on-language/#post-2497119)
 * Hi! I think that [this solution](http://wordpress.org/support/topic/polylang-multiple-headers)
   will be easier for what marlora is asking.
 * It just work with the templates pages, not the functions or styles.
 * Greetings!

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

The topic ‘[Plugin: Polylang] Set body class depending on language’ is closed to
new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

 * 3 replies
 * 4 participants
 * Last reply from: [ChowKaiDeng](https://wordpress.org/support/users/chowkaideng/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-polylang-set-body-class-depending-on-language/#post-2497119)
 * Status: not a support question