- This topic has 15 replies, 3 voices, and was last updated 6 years, 2 months ago by Tom.
-
AuthorPosts
-
January 25, 2018 at 7:07 am #479674John Dowling
Hi Tom.
Overall I am loving GP!I also have polylang installed to have both french and english. One problem.
The search box works fine in english and delivers only english pages.
On the french side it never finds anything.If I use the built-in wordpress search widget both languages work perfectly
If I turn off polylang the GP search function works but delivers results from both languages.
Can you helpÉ
January 25, 2018 at 12:37 pm #479937TomLead DeveloperLead DeveloperHi there,
Any chance you can turn on the core search widget so I can inspect the code?
Let me know 🙂
January 26, 2018 at 7:09 am #480506John DowlingSure. I activated the search box in the footer of both languages.
January 26, 2018 at 9:57 am #480638TomLead DeveloperLead DeveloperJust dove into their code a bit, let’s try this function:
add_filter( 'generate_navigation_search_output', 'tu_polylang_navigation_search' ); function tu_polylang_navigation_search( $search ) { if ( ! function_exists( 'pll_current_language' ) ) { return $search; } printf( // WPCS: XSS ok, sanitization ok. '<form method="get" class="search-form navigation-search" action="%1$s"> <input type="search" class="search-field" value="%2$s" name="s" title="%3$s" /> </form>', esc_url( home_url() ) . '/' . pll_current_language(), esc_attr( get_search_query() ), esc_attr_x( 'Search', 'label', 'generatepress' ) ); }
Let me know 🙂
January 26, 2018 at 1:06 pm #480734John DowlingWhere does it go?
January 26, 2018 at 4:47 pm #480821LeoStaffCustomer SupportOne of these methods here: https://docs.generatepress.com/article/adding-php/
Code snippet is usually what I use unless you are using a child theme.
January 26, 2018 at 5:58 pm #480853John DowlingInstalled Code snippet. Set to run everywhere. Sadly no luck
January 26, 2018 at 11:34 pm #480921TomLead DeveloperLead DeveloperI just dug through some of the Polylang documentation and made a change to the code above.
Can you try it and let me know?
Thanks!
January 27, 2018 at 3:42 am #480985John DowlingNow both languages don’t work. Any search give: Oops! That page can’t be found.
(When the snippet is deactivated and you search for something that isn’t there you get “Nothing found”)January 27, 2018 at 9:26 am #481224TomLead DeveloperLead DeveloperGrr. Is the snippet still active?
January 27, 2018 at 12:20 pm #481311John Dowlingit is now.
The search in english works. But if you then search from the results page you get the error messageJanuary 28, 2018 at 12:33 am #481482TomLead DeveloperLead DeveloperAlright, let’s try this again: https://generatepress.com/forums/topic/polylang-gp-conflict/#post-480638
I believe I’m using the right function now.
January 28, 2018 at 10:00 am #481851John DowlingWorks!! Thanks!
Only bug is if you click on English when you are in the French search results page you get the file not found message. Then if you click again you go to english home page. Maybe that’s a separate language switch problem?
January 28, 2018 at 10:06 am #481857TomLead DeveloperLead DeveloperThat may be worth checking with Polylang support about. If it’s something we need to do on our end, I’ll see what I can do 🙂
Thanks!
January 28, 2018 at 12:08 pm #481912John DowlingI think I’ll leave it for now as not likely thing for people to do.
Thanks for your help!! -
AuthorPosts
- You must be logged in to reply to this topic.