I am using WMPL+TOOLSET to build a bilingual site, the most important feature is submit forms on front-end and displaying on the posts. I have translated the post layout, cred forms and every custom field and label. it shows up correctly in cred forms, but the custom fields still show original language in posts.
My questions are:
1st, how to automatically translate custom fields in posts, since major contents are select, radio fields and media fields. all fields have been translated or no need to translate.
2nd, how can I use original language slug for bilingual site, because my second language site is Chinese, slugs in chinese can not be identified by some browser, so I just want to keep original English slug to second language site.
Best regards
Dear Jeffrey,
Q1) how to automatically translate custom fields in posts,
There isn't such a built-in feature within CRED or WPML, I suggest you try with CRED action hook cred_save_data, when user submit the CRED form, use action hook cred_save_data to trigger a PHP function, do these:
1) get the related translated value
https://developer.wordpress.org/reference/functions/get_post_meta/
2) save it into new post
https://developer.wordpress.org/reference/functions/update_post_meta/
More help:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
Q2) how can I use original language slug for bilingual site
Same as above, you can use CRED action hook cred_save_data to trgger a PHP function, do these
1) Get the post ID of original language
https://wpml.org/wpml-hook/wpml_object_id/
2) get the value of post permalink
https://developer.wordpress.org/reference/functions/get_permalink/
3) Save it into new post:
https://developer.wordpress.org/reference/functions/wp_update_post/
it is hard work to me? could you please help with it? Thanks 🙂
It needs custom codes, if you need more assistance for it, please provide a test site with same problem, and fill below "private detail box" with login details, also point out the problem page URL and CRED form URL, where I can edit your PHP codes, I need a live website to test and debug, thanks
Hi Luo, Thank you so much for you great help. Ihave been very busy recently, to go online, I just want to hold this ticket, and I will send information for you to access my wp account soon after. whenever you see my ticket, please resend the private link to me again. Thanks a lot! 🙂
As your request, I enabled the "private detail box" again, please also point out the problem page URL and CRED form URL, where I can edit your PHP codes, I need a live website to test and debug, thanks