WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] Static home page class issue (6 posts)

  1. RavanH
    Member
    Posted 2 years ago #

    Hi,

    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 :(

    http://wordpress.org/extend/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    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 ?

  3. RavanH
    Member
    Posted 2 years ago #

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

  4. RavanH
    Member
    Posted 2 years ago #

    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! :)

  5. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    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');
  6. RavanH
    Member
    Posted 2 years ago #

    Excellent stuff :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags