Ok, so I’m trying to automate the generation of posts and custom taxonomies in different languages, and it’s all working.
What I did (summary):
- create posts with wp_insert_post()
- set language of posts with pll_set_post_language(), for each
- associate respective post translations with pll_save_post_translations()
- create taxonomy terms with wp_insert_term()
- set language of terms with pll_set_term_language(), for each
- Associate custom taxonomy terms to custom post types with wp_set_object_terms(), for each
I completely see the use of these six functions.
Now, what I wonder is: What would be the advantage of additionally associating taxonomy term translations with pll_save_term_translations()? Given that, when you switch the website’s language, the posts will be displayed in the according language, with this also comes the switch of their taxonomy terms to the corresponding language, simply because it’s another post. So, in this case, what’s the benefit of using pll_save_term_translations()? I only see benefits in associating translated taxonomy terms with each other if you want to display their name separately and indepently from other wordpress objects which carry them language – specifically, such as posts. Is that the sense of it, or am I missing something, and pll_save_term_translations() is indeed mandatory for what I want to do? (which is programmatically prepare posts and their taxonomies, such that a post gets always displayed with its taxonomy terms in the right language, which is currently chosen by the language switcher)