WordPress.org

Ready to get started?Download WordPress

Forums

add qTranslate langs to header (6 posts)

  1. kvspublic
    Member
    Posted 2 years ago #

    Add this code to "header.php":

    <?php
      global $q_config;
      if(is_404()) $url = get_option('home'); else $url = '';
      echo '<ul id="headerMenuSystem">';
    
      foreach(qtrans_getSortedLanguages() as $language)
      {
        $link = qtrans_convertURL('', $language);
    
        if($_SERVER["HTTPS"] == "on")
          $link = preg_replace('#^http://#','https://', $link);
    
        echo '<li class="menu_item"><a href="'.$link.'"';
        echo ' hreflang="'.$language.'" title="'.$q_config['language_name'][$language].'"';
        echo '><span';
        echo '>'.$q_config['language_name'][$language].'</span></a></li>';
      }
    
      echo '</ul>';
    ?>
  2. TimoElshof
    Member
    Posted 1 year ago #

    Thanks, this helps! Can you help me with removing the bullets? I also would like to have flags ('images') in php? Can you help me with that as well?

  3. kvspublic
    Member
    Posted 1 year ago #

    About bullets: replace "menu_item" class.
    About flags: add "img" tag before "span".

  4. TimoElshof
    Member
    Posted 1 year ago #

    Thanks! I removed the bullets in my CSS with:

    #headerMenuSystem { list-style: none; }

    Do you know how to display the languages next to each other/horizontal?

  5. kvspublic
    Member
    Posted 1 year ago #

    replace "ul" by "table", "li" by "tr" and "td"

  6. TimoElshof
    Member
    Posted 1 year ago #

    I did it in the CSS:

    #headerMenuSystem li { float:left; width:auto; padding:0 10px 0 0; }

Topic Closed

This topic has been closed to new replies.

About this Topic