• Resolved Houdini

    (@romariokg)


    Hello.

    There is a problem with the search on the site, when switching the language from the main to the additional one, the locale of the language is added at the end of the URL, for example /ru, because of this the search does not work, can I somehow fix this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Andrei

    (@andrei202)

    Hey there,

    TP works with normal WordPress search, but custom queries search or ajax search may not work as they will continue to search in the original language.

    Any plugin that is doing FILTERING based on taxonomy or custom fields will work.
    You can use WP_Query with the query[‘s’] parameter and it will work out-of-the-box to provide relevant posts for that key term.

    The key term needs to be in same language as the current language being displayed when loading that page. In code, posts returned will be in the default language (IDs, post title, post content etc.) but the content echoed is translated on a later hook, so it will be displayed in the translated language in front-end.

    Only post title and post content are searchable in translated languages, external custom fields such as ACF are not. Depending on your setup, if you can include custom fields content inside the_content hook, then the custom fields are searchable as well.

    We have documentation about how you can implement a custom search solution: https://translatepress.com/docs/developers/implementing-a-custom-search-solution/.

    For the search to work on a specific post in a specific language, translation of that post content and title in that same language must exist prior to searching. If automatic translation is active, a post must be visited at least once in that specific language in order to get indexed by TP.
    However, any plugin that’s using an index, like SearchWP, will not work correctly with TranslatePress.

    Best Regards,

    Thread Starter Houdini

    (@romariokg)

    I tried to ensure compatibility with the search function, which does not use the default WordPress search engine through WP_Query. Using the given code on the search settings page, but WP throws an error when pasting the code into functions.php Can I contact support via email? I’ve been trying to set up the search for a long time but it doesn’t work.

    Andrei

    (@andrei202)

    Yes of course.

    You can reach out to us at here mentioning this conversation.

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