5

I am currently developing a plugin for multiposting on multisite wordpress.

I wanted the plugin to work with Polylang, it works well when it comes to setting the right language, but i can't find a way to connect to its other translations ( when i post from a blog to the others, otherwise on the same site, it works ).

I've searched in their documentation, and through their plugin, but did not found something that could actually help me.

Do you have any idea how I can set manually the link between translations of the same post ?

Thank's by advance ! :)

4

2 回答 2

2

这是pll_save_post_translations(对于翻译后关系)和pll_save_term_translations(对于翻译术语关系)都在 中定义的目的/wp-content/plugins/polylang/include/api.php

这两个函数都将等待一个关联数组:

  • 键:2 个字母的 ISO 语言代码(即“en”)
  • 值:post id 或 term id
于 2017-02-28T09:49:46.017 回答
1

我找到了解决方案。

您只需要像这样创建一个 wp_insert_term,并使用不同的描述:

wp_insert_term($group = uniqid('pll_'), 'post_translations', array('description' => serialize(['fr' => 453, 'en' => 455])));

然后将此术语设置为您关注的帖子或自定义帖子:

wp_set_object_terms( $postId, yourTerm, 'post_translations');

在这里,您的帖子已在您的后端正确链接!

于 2016-10-07T15:10:23.303 回答