Skip to content

Instantly share code, notes, and snippets.

@miguelpeixe
Created September 12, 2013 19:36
Show Gist options
  • Save miguelpeixe/6542747 to your computer and use it in GitHub Desktop.
Save miguelpeixe/6542747 to your computer and use it in GitHub Desktop.
Programatic qTranslate nav menu
<?php if(function_exists('qtrans_getLanguage')) : ?>
<nav id="langnav">
<ul>
<?php
global $q_config;
if(is_404()) $url = get_option('home'); else $url = '';
$current = qtrans_getLanguage();
foreach($q_config['enabled_languages'] as $language) {
$attrs = '';
if($language == $current)
$attrs = 'class="active"';
echo '<li><a href="' . qtrans_convertURL($url, $language) . '" ' . $attrs . '>' . $language . '</a></li>';
}
?>
</ul>
</nav>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment