Support » Plugin: Multisite Language Switcher » [Plugin: Multisite Language Switcher] Change the output

  • Resolved lissyg22



    First of all, thanks for this great plugin. I’m using it with my en/es website and it’s working perfectly, but there’s a thing I’d like to change. Right now the flags are showing in the header of my website (cause I added the function you said in the wiki in the header.php of my theme) but I would like it to appear in my navigation menu instead. I saw the “Manipulate the Navigation Menu” part in the same wiki but I still don’t understand where I would have to add this code.

    I know this could be a super dumb question, but I’m new at this.
    Thanks in advance.


Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Dennis Ploetner


    No problem. You can insert the code in your functions.php of your theme.

    Hi, I am also trying to put the switcher in the menu. I copied the code “as is” (except that I changed the menu name) in the functions.php file of my theme but absolutely nothing happens. Did I need to change, add, remove anything from the code? (I don’t know PHP so can hardly figure it out just with the instructions given). Is there something I can do to check why it’s not “acting on” the function?

    I am pretty sure that the plugins’s settings are all ok since the widget works if I activate it. Thank you!

    Plugin Author Dennis Ploetner


    This is the solution if you want the switcher integrated in your WordPress menu. But there are other ways to create a similar output. Can you give me an example? Is there already a site where I can see something?

    Thank you for your quick reply.

    This is the site I am trying to put the language switcher on : . I have searched in the source code to see if anything was there but was not showing in the page, but there is nothing. I am using a bought theme, maybe there is something conflicting?

    I have activated the widget feature in the footer so you can see that this part is working properly.

    Ideally I would like to have the description link (no flag) in the secondary menu on the left (beside “Accueil | Contact”).

    Plugin Author Dennis Ploetner


    The name of the menu seems to be “top_menu”, isn’t it?

    Yes, it seems like it… I have tried “top” and “top_menu” instead of “primary” in the code, but it doesn’t make it work. It is currently set as “top_menu”.

    Plugin Author Dennis Ploetner


    Could you check in your functions.php if the id of the menu is really top_menu? There must be at least one call to the function wp_nav_menu.

    Haa! thank you so much 🙂 Turns out the only call to wp_nav_menu was in the header.php. I was able to see there that the menu id was really top_menu, but it’s “theme location” was top-menu… Thank you again!!

    Plugin Author Dennis Ploetner


    OK, excellent!!


    I’d like to place the flags into the menu on my site too.

    I’ve copied the code from here into my functions.php file but nothing happens.

    I’m running twentytwelve here – Photoed.

    Can you help at all please?

    Plugin Author Dennis Ploetner


    I use Twenty Twelve on my test-installation. Could you please check if your menu-function is similar to my function my_custom_menu_item.


    Thanks for the swift reply.

    The menu function in my functions.php is

    // This theme uses wp_nav_menu() in one location.
    	register_nav_menu( 'primary', __( 'Primary Menu', 'twentytwelve' ) );

    Apologies if this is not the correct information. I am not particularly knowledgeable about code.

    Plugin Author Dennis Ploetner


    OK, so you could insert this code in your functions.php (I hope you are using a Child Theme):

    function my_custom_menu_item( $items, $args ) {
        if (
            class_exists( 'MslsOutput' ) &&
            'primary' == $args->theme_location
        ) {
            $obj = new MslsOutput;
            $arr = $obj->get( 2 );
            if ( !empty( $arr ) ) {
                $items .= '<li>' . implode( '</li><li>', $arr ) . '</li>';
        return $items;
    add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2 );


    I have copied that code into the functions.php of my (newly created, thanks) child theme but it doesn’t seem to have any effect on the menu.

    I have the plugin working perfectly from the sidebar widget so I know it’s not a fault with the plugin generally.

    I would like for it to show in the menu too since I prefer not to have the sidebar activated on the front page.

    Thanks again for your assistance.


    In fact, don’t worry.

    I will change my site to have the sidebar on the front page too.

    It would be the simplest solution I think.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘[Plugin: Multisite Language Switcher] Change the output’ is closed to new replies.