Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1403544
    underthebo
    Participant

    Hi,

    Whatever languages we are using with the search on X Theme (+WPML) the results are only in English….
    How to get them in the appropriate language ?
    For example if I am on the French version : https://underthebo.com/?lang=fr
    And looking for Bronze, the theme brings me to this page https://underthebo.com/?s=bronze and show only English results…
    It is like if the “lang=fr” is missing…., should be https://underthebo.com/?s=bronze&lang=fr

    Thanks for you help

    #1403676
    Christian
    Moderator

    Hey there,

    To make the search form multilingual, you need to modify searchform.php. Please copy searchform.php located in wp-content\themes\x to the same folder structure in your child theme wp-content\themes\x-child. Open the copied file then insert this code

    <input type="hidden" name="lang" value="<?php echo(ICL_LANGUAGE_CODE); ?>"/>

    below the line

    <input type="text" id="s" class="search-query" name="s" placeholder="<?php esc_attr_e( 'Search', '__x__' ); ?>" />

    Thanks.

    #1403685
    underthebo
    Participant

    Hi Christian,

    Thank you, but it’s still showing only English results…

    Please take look here : https://underthebo.com/?lang=fr and search for PETITE (=small in French) for example

    Thanks,

    #1403696
    Christian
    Moderator

    Please try adding the code below in your functions.php

    function x_navbar_searchform_overlay() {
    
      if ( x_get_option( 'x_header_search_enable' ) == '1' ) :
    
        ?>
    
        <div class="x-searchform-overlay">
          <div class="x-searchform-overlay-inner">
            <div class="x-container max width">
              <form method="get" id="searchform" class="form-search center-text" action="<?php echo esc_url( home_url( '/' ) ); ?>">
                <label for="s" class="cfc-h-tx tt-upper"><?php _e( 'Type and Press &ldquo;enter&rdquo; to Search', '__x__' ); ?></label>
                <input type="text" id="s" class="search-query cfc-h-tx center-text tt-upper" name="s">
                <input type="hidden" name="lang" value="<?php echo(ICL_LANGUAGE_CODE); ?>"/>
              </form>
            </div>
          </div>
        </div>
    
        <?php
    
      endif;
    
    }
    add_action( 'x_before_site_end', 'x_navbar_searchform_overlay' );

    Thanks.

    #1403707
    underthebo
    Participant

    Thanks again Christian but still not working….

    Is there a way to pass this information in the URL ?
    I we can to get something like https://underthebo.com/?s=petite&lang=fr it will work

    Thanks

    #1403761
    Christian
    Moderator

    The code should do that for you. But since it doesn’t work, you’ll need to contact WPML support for them to investigate your settings. Please tell them what you’ve done to the templates already.

    Thanks.

  • <script> jQuery(function($){ $("#no-reply-1403544 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>