Before you ask please READ THIS

Search form works only in english

in Fame Posts: 119
Hi man,
I was checking my site (I think you know it know... :-)) and so that the form search get results only in english.
I was trying some solution around before contacting you, but honestly I do dnot know what to write and where.
So before changing the cose I preferred to ask you.
On wpml I found this page but I cannot understand where to write that code to let the form working... https://wpml.org/documentation/support/creating-multilingual-wordpress-themes/search-form/
Or do you have any other idea to let it display result in italian?
Thanks man
Gabriele

Comments

  • AirAir
    Posts: 10,970
    Hello :-)

    Thanks for info about that. As I read making search result to show in both languages while being on english version is not easy. However below code will fix search results for other language.

    Go to fame\advance\utilities\layout_parts.php and find similar code in line ~32, and replace it with what you have below
    
    if(!function_exists('a13_search_form')){
        function a13_search_form() {
            static $search_id = 1;
    	    global $apollo13;
    
            $wpml_active = defined( 'ICL_SITEPRESS_VERSION');
    	    $shop_search_option = @$apollo13->get_option( 'settings', 'shop_search' );
    	    $shop_search = $shop_search_option === 'on';
            $helper_search = get_search_query() == '' ? true : false;
            $field_search = '<input' .
                ' placeholder="' . esc_attr(__('Search', 'fame' )) . '" ' .
                'type="search" name="s" id="s' . $search_id . '" value="' .
                esc_attr( $helper_search ? '' : get_search_query() ) .
                '" />';
    
            $form = '
                    <form class="search-form" role="search" method="get" action="' . home_url( '/' ) . '" >
                        <fieldset class="semantic">
                            ' . $field_search . '
                            <input type="submit" id="searchsubmit' . $search_id . '" title="'. esc_attr( __('Search', 'fame' ) ) .'" value=" " />
                            '.($shop_search? '<input type="hidden" value="product" name="post_type">' : '').'
                            '.($wpml_active? ('<input type="hidden" name="lang" value="'.ICL_LANGUAGE_CODE.'"/>') : '').'
                        </fieldset>
                    </form>';
    
            //next call will have different ID
            $search_id++;
            return $form;
        }
    }
    With kind regards.
  • Posts: 119
    It works... thanks a lot man..
    Wanna give me a job to test your themes??? ahahahah
    Thanks again... appreciate...
  • AirAir
    Posts: 10,970
    Would love to ;-)

    I will keep in mind when we will search for someone ;-)

    Have a great day.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion