How can I reset the search filter when changing languages?

This topic contains 32 replies, has 3 voices, and was last updated by  Alexander Krutov 5 years, 6 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #505547

    Alexander Krutov
    Expired Member
    Post count: 652

    WPML proposed the following solution: separate translations at /search/ pages. Then the site will translate the user to the home page of the secondary language when changing the language. This would be fine for me, but it turned out that this solution works only if the GeoDirectory Multilingual plugin is disabled. 🙁

    You can see this now.

    I also found out that the “Full wight” template does not work for untranslated Search pages.

    #505685

    Alexander Krutov
    Expired Member
    Post count: 652
    This reply has been marked as private.
    #505687

    Alexander Krutov
    Expired Member
    Post count: 652
    This reply has been marked as private.
    #505719

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
    #505725

    Alexander Krutov
    Expired Member
    Post count: 652
    This reply has been marked as private.
    #505834

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
    #505838

    Alexander Krutov
    Expired Member
    Post count: 652
    This reply has been marked as private.
    #505847

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
    #505848

    Alexander Krutov
    Expired Member
    Post count: 652
    This reply has been marked as private.
    #505852

    Alexander Krutov
    Expired Member
    Post count: 652
    This reply has been marked as private.
    #505853

    Alexander Krutov
    Expired Member
    Post count: 652
    This reply has been marked as private.
    #505854

    Alexander Krutov
    Expired Member
    Post count: 652
    This reply has been marked as private.
    #506065

    Kiran
    Moderator
    Post count: 7069

    Hi,

    your offer is better than WPML’s. This saves the category value and the search word in the search filter. How do I do that?
    I’m wondering if we can redirect a user to a search page in the active country.
    Add following PHP snippet to do that.

    
    
    /**
     * Redirect to default country.
     */
    function gd_snippet_20190902_wpml_url_parameters_gets_passed( $gets_passed, $code, $url ) {
    	global $geodirectory;
    
    	if ( ! empty( $_REQUEST['geodir_search'] ) && ! empty( $gets_passed['geodir_search'] ) ) {
    		$set_country = false;
    		if ( ! empty( $gets_passed['spost_category'] ) ) {
    			$set_country = true;
    			unset( $gets_passed['spost_category'] ); // Skip category
    		}
    		if ( ! empty( $gets_passed['city'] ) ) {
    			$set_country = true;
    			unset( $gets_passed['city'] ); // Skip city
    		}
    		if ( $set_country && ! empty( $geodirectory->location->country_slug ) ) {
    			$gets_passed['country'] = $geodirectory->location->country_slug;
    		}
    	}
    	return $gets_passed;
    }
    add_filter( 'geodir_wpml_url_parameters_gets_passed', 'gd_snippet_20190902_wpml_url_parameters_gets_passed', 20, 3 );

    Kiran

    #506074

    Alexander Krutov
    Expired Member
    Post count: 652

    Awesome! Thank you! Can you make the location page be redirected to the home page of the location of another language in the active country when switching to another language?

    #506189

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
Viewing 15 posts - 16 through 30 (of 33 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount