WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] [closed] menu for a theme does not change language (25 posts)

  1. acjo
    Member
    Posted 2 years ago #

    Hello,
    First of all thanks for the great plugin I really enjoy using it on my site.

    I wonder if you can help me with a bug that I have. I am using the theme Fullscreen by GraphPaperPress. I am able to create pages in 2 languages and have them change between languages without a problem. However the menu always stays fixed and never changes language.

    When I come to the homepage (created one english and one french menu) the change does not work:
    1. I don't see the flags to change language on the home page at the end of my menu.
    2. The default menu is english BUT I only ever see the french menu on the homepage or pages.
    If I type =en ou =fr in the url, the menu stays stuck on french.

    Can you tell me why the menu's don't change language even thought the site (url) and pages do?

    For info, the 2 menus are not identical, does this have an impact?

    Thank you very much for your time.

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

  2. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    Could you give me a link ?

  3. acjo
    Member
    Posted 2 years ago #

    http://www.acjowedding.com/
    Work in progress ;)

  4. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    So if I well understand, you created 2 menus (one in French, one in English) in Appearence->menus

    then you went to Settings->languages->menus
    You assigned each menu to its language
    You checked "Displays a language switcher at the end of the menu" and "Display flags"
    And it does not work as expected. Am I right ?

  5. acjo
    Member
    Posted 2 years ago #

    That is exactly what i have done. And the menu french is the only one i see.
    Ps. Thanks for the quick response.

  6. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    Well, it seems that your theme does not work in a standard way. For example, there is such an issue with Artisteer generated themes.

    Could you look into your theme files (generally header.php) if there is a call to the function wp_nav_menu ?

  7. acjo
    Member
    Posted 2 years ago #

    Ok. I could not seem to find the function wp_nav_menu in the theme files.

    I am not an expert php programmer so I could not really adapt the solutions in the links you gave me above to my own problem.

    If it's any help to you, this is the theme that I have downloaded and used :
    http://graphpaperpress.com/themes/fullscreen/

  8. Sergeyl1984
    Member
    Posted 2 years ago #

    Hi Chouby,

    Thanks for explaining the topic.

    I have another issue, I installed Boldly theme on my WordPress (androidmonsters.com) and I struggle with homepage translation. The matter is that Boldly uses special options for homepage, including slider and columns which. In special boldly menu I can chose from pages which to assign for columns.

    I don't have a homepage page available for edit, so don't know how to create another language version for homepage.

    Appreciate your ideas very much.

    Sergey

  9. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    @acjo

    I did not believe the solution for artisteer themes would work for yours. It was just to say that a lot of themes don't use a standard way of creating menus and unfortunately I cannot imagine all them !

    If you did not find wp_nav_menu, it's not a good start... However I do not want to register. Please upload a zip file of your theme on your server and post a link here. I will try to look into the source code if I can find some time.

    @Sergeyl1984
    Create a plugin or a child theme. And add this code:

    <?php if (function_exists(pll_get_post)) {
    	add_filter('option_boldy_slider', 'my__boldy_slider');
    	function my_boldy_slider($value) {
    		return pll_get_post($value);
    	}
    }
    ?>

    Then create a translation of your 'Homepage Slider Images Page'. It should allow you to use different images on both homepages.

    Just look in the file home.php of your theme. You will see the other options used by your theme. You can do things similar as above (using pll_get_post to translate pages and posts and pll_get_term to translate categories and tags).

  10. acjo
    Member
    Posted 2 years ago #

    Ok I will upload the theme as soon as possible.

    Searching in the Header.php file I found that the menu is called by this function:

    <?php fullscreen_theme_nav(); ?>

    Does this help in any way? Looks like it is a custom function.

  11. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    No it doesn't help. I will need to look into the source code of this function to see how the menu is built.

  12. acjo
    Member
    Posted 2 years ago #

    Here is a link to download the zip:
    https://skydrive.live.com/redir.aspx?cid=39a988e8091310f3&resid=39A988E8091310F3!146&parid=39A988E8091310F3!142&authkey=!AFwllW7uIPc66uc
    PLease let me know when you have doanloaded it so I can take the files down. THanks

  13. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    You can remove the link.

  14. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    Well... The theme is using the standard way of creating menu (wp_nav_menu). But it is buggy as it is using a parameter not recognized by WordPress. It works on a monolingual site which created only one menu just because WordPress fallbacks to the first menu in that case.

    The correction is easy. Edit the file functions.php at line 41 and replace:

    wp_nav_menu( 'sort_column=menu_order&menu_location=main-menu&container_id=nav&menu_class=sf-menu' );

    by

    wp_nav_menu( 'sort_column=menu_order&theme_location=main-menu&container_id=nav&menu_class=sf-menu' );

    You can send a bug report to the author. It may help someone else ;-)

  15. acjo
    Member
    Posted 2 years ago #

    Brilliant! It works perfectly. Thanks alot.
    Now I just have to play around witht he CSS a little but to get the flags positioned just how I want them.
    Thanks for your help, you're a life saver.

  16. Sergeyl1984
    Member
    Posted 2 years ago #

    @Chouby

    Thanks a lot for reply and guidance, as I am new to WP, would very appreciate if you can explain how to create a plugin or a child theme. And where to add the code you mentioned?

    Thanks!
    Sergey

  17. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    The best is the personal plugin and its creation is very simple:

    Create a new file in your favorite text editor and paste this:

    <?php
    /*
    Plugin Name: MyPlugin
    */
    
    if (function_exists(pll_get_post)) {
    	add_filter('option_boldy_slider', 'my__boldy_slider');
    	function my_boldy_slider($value) {
    		return pll_get_post($value);
    	}
    }
    ?>

    Save it as 'whateveryouwant.php'. Then upload the file in wp-content/plugins/ directory. You then go activate your plugin in the plugins table an that's all !

    To know more:
    http://codex.wordpress.org/Writing_a_Plugin
    http://codex.wordpress.org/Child_Themes

  18. emily@duochjobbet.com
    Member
    Posted 2 years ago #

    @Chouby

    Hi, we have a similar menu problem. We have a custom built theme, using
    <?php wp_nav_menu(); ?> and <?php pll_the_languages(array('show_flags'=>1,'show_names'=>0)); ?> in header file.

    We have followed instructons/settings for installing Polylang and everything seems to work but the menu. We have 2 menus (created in admin), one in swedish and one in english. But the menu stays in swedish at all times, while content changes to english when you press the english flag.

    Can you possibly know what can be missing? Here's a link to the site; http://www.processtodstockholm.se

    Thanks in advance.
    Emily

  19. emily@duochjobbet.com
    Member
    Posted 2 years ago #

    @Chouby

    Hi again,

    Solved it with this http://wordpress.org/support/topic/plugin-polylang-multilingual-menus-1?replies=4

    You should add this in the instructions:

    For Polylang to work, the theme_location must be defined but not the menu.

    Something like:
    wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?> is OK

    Something like:
    wp_nav_menu( array('menu' => 'Project Nav' ));
    is not OK

    =) Great plugin!! Best regards /E

  20. fabian.schmid
    Member
    Posted 2 years ago #

    Dear Chouby

    I love the theme however I'm having the same problem as well as a couple of others. I have created two menus, one for English (default one) and one for German. I set everything accordingly in Settings > Languages > Menus as mentioned above.

    The problems I'm having:
    - The menu does not change when the language flag is clicked
    - The string translations do not work
    - The widgets do not change accordingly to the chosen language (I added every widget twice, once for each language and set "The widget is displayed for" to the according language)

    The theme was created by myself (I used WP's twentyeleven as a blueprint) and the menu is being created with the following line in my header.php:
    <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>

    The website is: http://www.865artist.com

    I hope you're still gonna see my post since the last answer was written four months ago.

    Thanks

  21. fabian.schmid
    Member
    Posted 2 years ago #

    I found the problem. It is a plugin called 'Theme My Login' which enables you to create individual pages for the login, reset password and register pages.

    I really want that plugin though so if anyone can help me to allow both plugins to work together I'd be very grateful.

  22. imarosi
    Member
    Posted 1 year ago #

    Hi, I'm having a similar problem with my theme as well. the menu is called with

    <?php wp_nav_menu('main'); ?>

    and I can't get polylang to switch menus while on different languages. if I substitute the wp_nav_menu code with

    <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>

    the menus show perfectly but they don't apply a specific CSS style. i just started working with WP so I'm not that good with it's syntax. any help is apreciated.

  23. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Your theme author did not read the wp_nav_menu documentation... It's pure luck if it works as expected. Just because most users do not create more than one menu.

    Is your theme coming with an already existing menu called 'main'?
    If yes, I would try 'menu-main-container' as value for 'container_class' instead of 'menu-header'.

  24. Marshall
    Member
    Posted 1 year ago #

    Hi Chouby,
    Wondering if you could help me on this please.
    I have same problem and here is the header and the functions file.
    Could you please suggest a solutions.

    [ Code moderated. Please use pastebin.com instead. ]

  25. @lovemarshall as this has been marked resolved already and it's a different problem then yours please start your own topic instead.

    http://wordpress.org/support/plugin/polylang#postform

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags