Home › Toolset Professional Support › [Resolved] Posts created/updated in 2nd language only visible in 2nd language
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Our next available supporter will start replying to tickets in about 1.56 hours from now. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
Tagged: Custom search, Views, Views plugin
Related documentation:
This topic contains 26 replies, has 3 voices.
Last updated by simonM-5 4 years, 10 months ago.
Assisted by: Minesh.
I am trying to:
When logged in as a Family, trying to display/search/manage all Job Ads in any language.
Link to a page where the issue can be seen:
hidden link
I expected to see:
The Job ad should be searchable, editable and visible in all languages.
Instead, I got:
Any Job Ad which was created or edited in secondary languages (DE, ES) is - after saving - only searchable, editable and visible in that secondary language.
This is working fine for the Native Nanny Ads when logged in as a Nanny, ie with Nanny Ads, I can create a Nanny Ad in any language and it is visible, searchable, editable and translated in all other languages.
hidden link
Here are 2 logins you can use to log in as a Nanny to create Nanny Ads or as a Family to create Job Ads.
All data on the site is currently just test data, so feel free to create new Ads for test purposes. Passwords have been changed temporarily too.
updated additional access details
nativenanny6@freenet.de /
nativefamily6@web.de /
Thanks and regards
Simon
Hello. Thank you for contacting the Toolset support.
I checked both post types "native-nanny-ad" and "family-ad" and I do not see any translated posts:
=> hidden link
=> hidden link
Actually, views role is to display posts in the current language. And I see you do not have any translated posts available.
Do you mean that when you have translated posts available in languages (DE, ES) - and if the current language of your post/page is English where you added the view, you still want to display the translated posts belongs to languages (DE, ES)?
HI Minesh
If I create a Nanny Ad (which you are free to try yourself using one of the logins.. Log in as a Nanny and go to Account > Place an Ad). This Nanny Ad can then be viewed freely in any language and everything all taxonomies, titles etc are translated without having to go to WPML String Translation (with the exception of the free text field of course). Moreover the items can be found by performing the search in any language.
1 )However do the same for Job Ads (logged in as a family) and this is not the case.
2) If I am viewing the site in German and perform a search in German in Find a Job (logged in as a Nanny), the search results do not come back and the site switches to English. This doesn't happen in Find a Nanny (logged in as a Family)
I hope I was able to explain the issue well, please let me know if something is unclear.
Best regards
Simon
I checked the WPML settings and both "family-ad" and "native-nanny-ad" post types set to "Translatable - use translation if available or fallback to default language ". Please check the following screenshot:
=> hidden link
More info:
=> https://wpml.org/documentation/translating-your-contents/displaying-untranslated-content-on-pages-in-secondary-languages/
Now, I think you are talking about the post that belongs to post type "family-ad" with title "ES Family Job Add"
=> hidden link
When I checked the "ES Family Job Add" post it was showing as pending and I now published it.
=> hidden link
Do you see its working and you mean that "ES Family Job Add" should be available in search results correct irrespective of current language?
HI Minesh
Yes, we set both Custom Types Native Nanny Ads and Family Ads to "Translatable - use translation if available or fallback to default language " deliberately, because we are not translating the free text content of these, however all titles and taxonomies etc are translated, and this is working perfectly for Native Nanny Ads.
We have also already created Family Ads and set their status to Published, however they are then only visible under Account > Manage My Ads in the last language in which they were saved/updated. For example,
1) I log in as a Family, viewing the site in Spanish, I create an Ad and save it - it goes to Pending.
2) When we publish it, it is only visible under Account > Manage My Job Ads when viewing the site in Spanish, although it should be visible if I switch to German or English too.
With Nanny Ads, we can create, view, search, edit Nanny Ads freely in any language, as required. In other words, we want Job Ads to behave exactly like Nanny Ads.
I know it's a bit confusing, I hope I have explained it well.
Kind regards
Simon
first of all, I would like to know have you created the posts in default language EN With Nanny Ads or when you created those Nanny Ads posts are you using any different WPML settings or is there any custom code/hook added for forms to duplicate the Nanny Ads posts?
As "Translatable - use translation if available or fallback to default language " setting does not work if the post is not available in the default language and as you said you are creating the post in Spanish
and
if "Translatable - use translation if available or fallback to default language" setting is set the duplicate option will not be available with the post:
=> https://wpml.org/documentation/translating-your-contents/displaying-untranslated-content-on-pages-in-secondary-languages/using-content-duplication/#duplicating-content-from-the-editor
At that time, you need to use Batch duplicate from the Translation Management => Translation Dashboard
=> hidden link
As the Doc says duplicate will not be possible if you set the post type setting to"Translatable - use translation if available or fallback to default language", I wonder how fallback to default language works with your Nanny Ads posts. so, can you confirm did you duplicate posts or used any form API hook to duplicate the post?
HI Minesh
The Nanny Ads were simply created by a logging in as one of our fake Nannies and creating the Ad. They weren't created via WP Admin.
Also we did not duplicate any posts or use any API hooks to duplicate the posts. They were simply created via the front end.
Kind regards
Simon
Thanks for the confirmation that you are not using any form's API hook to duplicate the posts.
1) I log in as a Family, viewing the site in Spanish, I create an Ad and save it - it goes to Pending.
2) When we publish it, it is only visible under Account > Manage My Job Ads when viewing the site in Spanish, although it should be visible if I switch to German or English too.
===>
As you followed the following steps, as I said:
"Translatable - use translation if available or fallback to default language " setting will not work if the post is not available in the default language. As you created the post in the Spanish language, it must have a post available in default language then and then the settings you set " use translation if available or fallback to default language" will have an effect. That means the post you created using form is in Spanish language that is against the rule of setting "use translation if available or fallback to default language" that will actually require the post in the default language.
As you can see that all the posts for post type "native-nanny-ad" is available in the default language (EN) that is why it looks like working.
=> hidden link
What if you try to follow the following steps:
1) I log in as a Family, viewing the site in English, and create an Ad and save it - it goes to Pending.
2) When we publish it, it is only visible under Account > Manage My Job Ads when viewing the site in English and then also check if works for other languages?
Hi Minesh
OK, I understand now what you mean.
I can confirm that all Ads (Job or Nanny) created in EN (default) are all available in all languages, with the setting "Translatable - use translation if available or fallback to default language".
I tried with Family Ads to do the following:
1) Set the Custom Post Type Family Ads to the setting: Post Types Translation > Translatable - only show translated items
2) Batch duplicated all Family Ad Posts created in EN to ES and DE
3) Repeated for all Family Ad Posts created in DE to EN and ES, and also for ES to EN and DE
4) Was able to view see all content correctly in all the languages.
So, I can imagine a large majority of ours ads will be created in German or Spanish, so what would be the recommendation to set the WPML settings to for the Custom Post Types Nanny Ads and Family Ads?
Basically our requirements would be:
1) users should be able to create their Ads in any language
2) after an approval process, they will be set from Pending to Published
3) the majority of the Ad gets translated automatically (taxonomies translate automatically, the other two fields are simply numeric fields which don't need translation, and the one large text field, where users can write free text, is to remain untranslated)
4) once Published, Ads should be visible in any language.
Was this the correct approach?
Kind regards
Simon
Hello,
Minesh is on holiday today. He will be back on tomorrow. He will get in touch with you with the latest updates on this ticket on Friday.
To duplicate the posts automatically in other languages, I've added the following code to "Custom Code" section offered by Toolset with the snippet "duplicate-posts-all-languages":
=> hidden link
function func_wpml_duplicate_posts_in_all_languagtes( $post_id, $form_data ){ $forms = array( 921 ); if ( in_array($form_data['id'],$forms) ){ global $sitepress; do_action( 'wpml_make_post_duplicates', $post_id); } } add_action( 'cred_save_data', 'func_wpml_duplicate_posts_in_all_languagtes', 10, 2 );
Now, if you try to submit the form in Spanish and the posts will be automatically duplicated in other languages:
=> hidden link
Can you please check and let me know this helps you to resolve your issue.
Hi Minesh
I saw that you had created a toolset test 1 - ES Nanny Ad which I just set to Published and it appears to have duplicated into the other languages.
1) Does this happen only for Nanny Ads (logged in as a Nanny) or should it also happen for Job Ads (logged in as a Family). Does the number 921 here in your custom code refer to a post ID?
I believe I have created a new Job Ad which didn't get duplicated.
Thanks and regards
Simon
The code I shared with the following reply:
=> https://toolset.com/forums/topic/posts-created-updated-in-2nd-language-only-visible-in-2nd-language/#post-1425923
The hook will be triggered and make the duplicate posts in other languages when the form is submitted for the form ID 921. The 921 is the Toolset form ID.
So, if you want to make posts duplicate automatically for other forms you need to add the form ID to the following variable;
$forms = array( 921,999,888 );
Where:
- you and replace your form IDs with 999 and 888 for the forms for which you want to make duplicate posts when you submit the form.
Hi Minesh
I added 929 to the array to duplicate the Family (Job) Ad forms on submission also. It seems to have worked.
However this seems a little bit inefficient to me in the long term as all content on our site would be triplicated. It also kind of makes the purpose of WPML a little redundant, don't you think?
1) Is this the most efficient solution? What I am asking is, is this the recommended best practice - to duplicate and triplicate everything? Or is there a "slimmer" solution?
2) What about updates to forms which have already been submitted, what would be the expected behaviour in this case? Does an update count as a submission? In which case, would an update cause further triplicates to be created?
Kind regards
Simon
However this seems a little bit inefficient to me in the long term as all content on our site would be triplicated. It also kind of makes the purpose of WPML a little redundant, don't you think?
==>
I dont think so because you have two ways:
- Either add duplicate posts manually
- Use Toolset forms hook to duplicate the content
And you need to duplicate the post in all languages so that setting "Translatable - use translation if available or fallback to default language" should be in effect and mainly you need to duplicate post in the original EN language so the setting "Translatable - use translation if available or fallback to default language" should be respected.
1) Is this the most efficient solution? What I am asking is, is this the recommended best practice - to duplicate and triplicate everything? Or is there a "slimmer" solution?
==>
Again, we are there as the same point As I explained to you in the following reply:
- https://toolset.com/forums/topic/posts-created-updated-in-2nd-language-only-visible-in-2nd-language/#post-1421567
2) What about updates to forms which have already been submitted, what would be the expected behavior in this case? Does an update count as a submission? In which case, would an update cause further triplicates to be created?
==>
Update form code should be written and tested so that if duplicates are already available, it should not makes more duplicate. You should open a new ticket and share all the required information like where you added the post edit form with access details and assign it to me.