lissyg22
Member
Posted 8 months 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/
No problem. You can insert the code in your functions.php of your theme.
bellechan
Member
Posted 7 months 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!
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?
bellechan
Member
Posted 7 months 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").
The name of the menu seems to be "top_menu", isn't it?
bellechan
Member
Posted 7 months 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".
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.
bellechan
Member
Posted 7 months 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!!
Photoed
Member
Posted 2 months 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?
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.
Photoed
Member
Posted 2 months 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.
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!
Photoed
Member
Posted 2 months 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
Photoed
Member
Posted 2 months 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.
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!
Photoed
Member
Posted 2 months ago #
No problem,
It's a great plugin already!