• Resolved Ajay

    (@ajay)


    Hi,

    I’m the author of Contextual Related Posts. A user of our plugins posted a query out here and as I’m stuck on how TranslatePress works, hence my post.

    When browsing the English (default) language, my plugin properly detects the post title and content and passes this to the CRP_Query (which is a wrapper for WP_Query). However, when browsing the translated post, it only thinks it has blank strings and as a result my plugin can’t find any related posts.

    I’m not sure why that happens. Would you have any ideas?

    If it helps, here is the code used to get the post title and content of the post to be translated.

    https://github.com/WebberZone/contextual-related-posts/blob/v3.3.4/includes/class-crp-query.php#L446

Viewing 6 replies - 1 through 6 (of 6 total)
  • Looking for support from TranslatePress author related to the issue.

    Hey there,

    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.
    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, will not work correctly with TranslatePress.

    Let me know if you have any further questions

    Thread Starter Ajay

    (@ajay)

    Thanks Andrei. Is there a function to get the translated post title and translated post content?

    Right now it gets the title and content directly from the database against the post which I understand it won’t be able to get.

    Greetings,

    Please try using the trp_translate() function from here: https://translatepress.com/docs/translation-function/

    and let me know if it works.

    Plugin Support Anghel Emanuel

    (@anghelemanuel99)

    Hello there,

    Since 5 days have already passed from the last reply, I will consider this issue solved and I will mark it as “Resolved”.

    If there`s anything else, please let me know!

    Kind Regards,

    Thread Starter Ajay

    (@ajay)

    I haven’t had the time to test it. Please go ahead and mark this resolved. I’ll post again if I am stuck. Reality is if I can’t solve it using the above function then I won’t be able to!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘TranslatePress + Contextual Related Posts’ is closed to new replies.