[Resolved] How to pass WPML parameters to the new Navigation Search button

Home Forums Support [Resolved] How to pass WPML parameters to the new Navigation Search button

Home Forums Support How to pass WPML parameters to the new Navigation Search button

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2594834
    Andrew

    We just enabled the new navigation search which is great (https://generatepress.com/a-new-navigation-search/). We are using WPML with language parameters however so our website adds lang=fr to the url when the user is in french. When a user is in french and they click on the magnifying glass it open up the dialogue in French (as expected) however the search results are sent to the english page as the lang=fr is removed from the URL. Is there anyway we can preserve that URL argument or some sort of hook we can connect to so we can add the url parameter with JS or PHP. I’ve reached out to WPML who asked me to connect with the GP forum. Thanks!

    #2596062
    David
    Staff
    Customer Support

    Hi there,

    i must say, i have very little understanding of WPML or whether its getting in the way of these actions.
    If i inspect the search form i see the opening tag:

    <form role="search" method="get" class="search-modal-form" action="https://yourdomain.ca/?lang=fr">

    And we can see the action="https://yourdomain.ca/?lang=fr" includes the lang query string.
    So in theory that should be consider in the resulting search terms ie.

    https://yourdomain.ca/?lang=fr&s=my_search_term

    But it does not. Hmmm…

    How does the core Search Block perform ? Does it keep the lang parameter in the search results?

    To test this:

    1. In Appearance > Elements -> Add New –> Block Element.
    2. In the elements settings set the element type to Search Modal
    3. Add a core Search Block to the content.
    4. Set the Display Rules to the Entire site.

    This will swap our search form for that block.

    #2596190
    Andrew

    Hi David, thanks for the quick response. I don’t actually see a “settings” option when adding a block. Can you please confirm this is what I’m looking for https://ibb.co/f2xyB57. I’ll try out your solution to see if it works!

    Thanks, Andrew

    #2596284
    David
    Staff
    Customer Support

    Ah, are you using Classic Editor plugin ?

    #2596328
    Andrew

    Hi David, I was but I’ve disabled it and now everything shows up. I was also able to test and it turns out this solution does work! Thanks so much for sorting this out!

    #2596353
    David
    Staff
    Customer Support

    Ah, so it works with the core Search Block ?
    If so ill do some tests as to why the themes search doesn’t

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.