Support » Plugin: Polylang » [Plugin: Polylang] Static home page class issue

  • Resolved RavanH



    I really like this promessing plugin project for multi language support. Currently testing on multi-site, it does not have the drawback that qTranslate has: increased loss of speed when browsing.

    But there are still a few downsides (which is completely understandable for such a new project) … I’d like to bring up one for discussion if I may (or has it already been discussed?)

    I had set up a static home page, and next activated/configured Polylang, the plugin allowed me to add translation pages of the home page just fine but… Let’s say I set up a page called Home as homepage and then created a translation called Accueil (French) for it, then when visiting the front end home page for the French language that home page does not have the body class “home” anymore… In the case of my site, this breaks specific front page CSS rules 🙁

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Chouby


    You are probably facing a theme compatibility issue. Of course Polylang tries to tell the theme the translated homepage is the homepage, but sometimes theme authors make very special things 😉

    Is your theme freely downloadable ?

    It’s a child theme of Twenty Eleven with just a different style.css and no special templates or anything.

    To test, I switched to the plain Twenty Eleven but it has the same result. No home class for the alternative languages on the home page…

    Oh, and thanks for you quick response and attention to the matter! 🙂

    Plugin Author Chouby


    Thanks to you, I learned that body classes are managed by the WordPress core 🙂 So I will correct that in the next release.

    Waiting for it, here is a fix. Just add this code in your functions.php

    // add home class to body classes on translated frontpage
    function my_body_class($classes) {
    	if (function_exists('pll_is_front_page') && pll_is_front_page() && !is_front_page())
    		array_unshift($classes, 'home');
    	return $classes;
    add_filter('body_class', 'my_body_class');

    Excellent stuff 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Polylang] Static home page class issue’ is closed to new replies.