As well as Toolset I am running WPML with two languages.
I have created a custom post type called "Sightings" and one of the fields is a map location.
I have also created a Cred form to create posts from the front end. Once the form is submitted, it is set to be Published. I have a aslo used Cred API to assign a particualar taxonomy term.
I have created different forms for each language.
Once the form submission is made, the user is redirected to a page according to their language showing a map with all post markers. The new post marker appears on the map.
The map pin title should be displaying the term associated with the post. This works fine for my main language (english), but it does not show for my second language. This is regardless of which language version form I use.
My WPML settings are set to not translate both the post type and taxonomy.
Post creation forms:
hidden link
hidden link
My pages with View of all map locations are:
hidden link
hidden link
This is the code I am using to auto-assign the terms:
// automatically assign a slug to all posts created by CRED
add_action('cred_save_data', 'set_term_for_cred_post',10,2);
function set_term_for_cred_post($post_id, $form_data) {
// array of cred form IDs and corresponding term slugs
$array = [
'1527' => 'blood-veined-moth',
'1941' => 'blood-veined-moth'
];
$taxonomy = 'species';
$tag = array( $array[$form_data['id']] );
wp_set_object_terms( $post_id, $tag, $taxonomy, true );
}
Hi, I don't see anything obviously wrong in your setup or custom code. A quick test in a similar setup on my local shows the taxonomy terms displayed correctly in a secondary language View, so I must be missing something. Is it okay for me to submit the Form and create some test posts? Is it okay for me to temporarily deactivate some plugins for testing? I can see a Maintenance Mode plugin is active but didn't want to assume.
Hi, thanks for looking.
Sure you can create some test posts and use maintenance mode if you need to.
Interesting to hear this works in a test environment. It does seem to be one of those things that should just work.
I had a feeling this could be a remnant of migrating from q-translateX after creating the CPT and the taxonomy.
So I removed and recreate those, but it didn't help.
Just thinking, a workaround for this might be to set the terms in both languages.
But I am not sure how to set multiple terms on cred save data. My attempts thus far have all failed.
I've escalated this to my 2nd tier support team for some additional information. I'll give you some feedback when I have received a response.
OK, thanks for continuing to look into it.
Hi, just a quick update to let you know I'm still discussing this with the team and I have a few outstanding concerns. I hope to receive more information by tomorrow and I can provide another update.
I had a feeling this could be a remnant of migrating from q-translateX after creating the CPT and the taxonomy.
This is possible, since the root of the problem seems to be that the taxonomy terms have entries in the wp_icl_translations database table. Those entries indicate the terms have been translated, though they should not be. So in our local tests the solution was a manual database cleanup:
1. Open the wp_icl_translations table in the database
2. Find all occurrences of tax_species in column element_type of that table (see the screenshot here)
3. Delete those rows
4. Open the Sighting post ID #2016 in wp-admin and resave it. The title is "test1-1581379200", for your reference.
Now test the maps again. All terms appear in markers in both language maps. If I create a new post in the English Form with a new test term in the cred_save_data hook, that term appears in both language maps. If I create a new post in the Welsh Form with a new test term, that term appears in both language maps.
So I think we have a viable solution. If you're comfortable using phpMyAdmin or another MySQL GUI tool to make these changes, please create a backup of your entire database before making any edits. Then follow the steps outlined above to delete the tax_species entries from the wp_icl_translations table. If you're not comfortable making those changes, I am happy to do them for you but I'll need access to your server control panel. Let me know how you would like to proceed.
That seems to have done the trick. Thank you very much for taking the time to look into this in such detail.