Add WPML Language Switcher To Topbar

Hello,

I want to add the WPML language switcher to my X Pro topbar. I already copied the _topbar.php file into my child theme. When I add the php or shortcode given to me by the WPML documentation (https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/#custom-locations) it just shows the code itself on the website. I really want it to look like other websites that I have done when using the G-Translate plugin. I’ll include a screenshot below of what im looking to accomplish. I have added icons to the topbar on other sites and needed to add a code to the functions.php file to make them actually display. I feel like this is a similar situation.

I have since figured this out. If anyone else needs to know this was the solution.

<?php

// =============================================================================
// VIEWS/GLOBAL/_TOPBAR.PHP
// -----------------------------------------------------------------------------
// Includes topbar output.
// =============================================================================

?>

<?php if ( x_get_option( 'x_topbar_display' ) == '1' ) : ?>

  <div class="x-topbar">
    <div class="x-topbar-inner x-container max width">
      <?php if ( x_get_option( 'x_topbar_content' ) != '' ) : ?>
      <p class="p-info"><?php echo x_get_option( 'x_topbar_content' ); ?></p>
      <?php endif; ?>
      <?php x_social_global(); ?>
	  <div class="wpml-translate"><?php echo do_shortcode('[wpml_language_selector_widget] '); ?></div>
    </div>
  </div>

<?php endif; ?>

Hi @Contourandco,

Thank you for reaching out to us. Your solution seems correct but I hope you’ve made the template changes in your Child Theme so your code changes won’t be overwritten when a theme update is released.

Thank you for sharing the solution with us. Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.