WordPress.org

Ready to get started?Download WordPress

Forums

Multisite Language Switcher
[resolved] Change the output (18 posts)

  1. lissyg22
    Member
    Posted 1 year ago #

    Hi

    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.

    Lissy

    http://wordpress.org/extend/plugins/multisite-language-switcher/

  2. realloc
    Member
    Plugin Author

    Posted 1 year ago #

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

  3. bellechan
    Member
    Posted 1 year ago #

    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!

  4. realloc
    Member
    Plugin Author

    Posted 1 year ago #

    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?

  5. bellechan
    Member
    Posted 1 year ago #

    Thank you for your quick reply.

    This is the site I am trying to put the language switcher on : http://www.prestigeexperts.com/fr/ . 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").

  6. realloc
    Member
    Plugin Author

    Posted 1 year ago #

    The name of the menu seems to be "top_menu", isn't it?

  7. bellechan
    Member
    Posted 1 year ago #

    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".

  8. realloc
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  9. bellechan
    Member
    Posted 1 year ago #

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

  10. realloc
    Member
    Plugin Author

    Posted 1 year ago #

    OK, excellent!!

  11. Photoed
    Member
    Posted 1 year ago #

    Hi,

    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?

  12. realloc
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  13. Photoed
    Member
    Posted 1 year ago #

    Hi,

    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.

  14. realloc
    Member
    Plugin Author

    Posted 1 year ago #

    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 );

    Cheers!

  15. Photoed
    Member
    Posted 1 year ago #

    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.

    Edward

  16. Photoed
    Member
    Posted 1 year ago #

    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.

  17. realloc
    Member
    Plugin Author

    Posted 1 year ago #

    It should work with Twenty Twelve but I will implement better integration into the menus in one of the next versions of the plugin. Thanks for bringing this to my attention!

  18. Photoed
    Member
    Posted 1 year ago #

    No problem,

    It's a great plugin already!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.