This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 3 replies, has 2 voices.

Last updated by Bruno 5 years, 7 months ago.

Assigned support staff: Bruno.

Author Posts
August 28, 2013 at 7:26 pm #158578

Irene

Hi,

I'd like to have a flags-only in my top-bar menu. Preferably the language that is currently NOT shown.

I've tried:
- just about every piece of code I found on this forum
- the WPML flag in menu plugin: It works, but the flags now show up twice, one in the top bar and one in the main menu just below.
- the WPML flag in menu extend plugin: doesn't work, no flags show up at all.

Any ideas would be highly appreciated!

Thanks!

Irene

August 28, 2013 at 7:48 pm #158583

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Dear Irene,

Please add this function into the functions.php file of your theme:

function wpml_custom_lang158578(){
	if(function_exists('icl_get_languages')):
		$languages = icl_get_languages('skip_missing=1&orderby=custom');
		
		if(count($languages) >= 1):		
		foreach((array)$languages as $language):
			if($language['active'] != 1): 
		?>
			<span class="icl-<?php echo $language['language_code']; ?><?php echo $language['active'] == 1 ? ' icl-current' : ''; ?>">          
				<a rel="alternate" hreflang="<?php echo $language['language_code']; ?>" href="<?php echo $language['url']; ?>"><img src="<?php echo $language['country_flag_url']; ?>" alt="<?php echo $language['native_name']; ?>" title="<?php echo $language['native_name']; ?>" /></a> 
			</span>
		<?php
			endif;
		endforeach;
		endif;
	endif;
}

Then call the function where you want to display the flags.

<?php wpml_custom_lang158578(); ?>

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Thank you.

August 29, 2013 at 5:05 am #158631

Irene

Dear Bruno,

thank you for the code.
I've tried adding it to the functions.php file and then inserted the below code in topbar.php.
I'm not quite sure where exactly to put the code.

I've been reading you have to input it in functions.php before the end tag. However, my functions.php doesn't have an end tag. All that's there is this code:

<?php
//let's start the game!
require_once('core/load.php');

Here's the code from the topbar:

<?php
/**
* Your Inspiration Themes
*
* @package WordPress
* @subpackage Your Inspiration Themes
* @author Your Inspiration Themes Team <info@yithemes.com>
*
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* hidden link
*/

?>

<?php if( yit_get_option('topbar') ): ?>
<!-- START TOP BAR -->
<div id="topbar">
<div class="container">
<div class="row">
<?php get_sidebar( 'header' ) ?>
</div>
</div>

</div>

<script>
jQuery(function($){
var twitterSlider = function(){
$('#topbar .last-tweets ul').addClass('slides');
$('#topbar .last-tweets').flexslider({
animation: "fade",
slideshowSpeed: 5 * 1000,
animationDuration: 700,
directionNav: false,
controlNav: false,
keyboardNav: false
});
};
$('#topbar .last-tweets > div').bind('tweetable_loaded', function(){
twitterSlider();
});
});
</script>

<?php wpml_custom_lang158578(); ?>

<?php endif ?>

Any ideas?

Thank you!

Irene

August 29, 2013 at 1:28 pm #158877

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Dear Irene,

Your code looks like it has an option to enable and disable topbar.php:

<?php if( yit_get_option('topbar') ): ?>

....
<?php wpml_custom_lang158578(); ?>
....

<?php endif; ?>

Since you have added the function call of the flags within this condition, please make sure that the option of topbar is active within your theme.

Please let me know if this solves the problem and if I can help with anything else.

Thank you.

The topic ‘[Closed] Problem with flag-only in top bar navigation’ is closed to new replies.