Skip Navigation

[Resolved] Problem linking posts with multiple languages

This support ticket is created 2 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 5 replies, has 2 voices.

Last updated by Mateus Getulio 2 years, 1 month ago.

Assisted by: Mateus Getulio.

Author
Posts
#2471421

Hello,
i have a problem with toolset.
Within a post "Brics Laboratory" (hidden link) I related the posts "Observatory documents" each one is translated into 2 languages (not all and now I'll explain what happens).

When I "link" an "observatory document" in the Italian language (hidden link), if it also exists in English I can see it correctly also in the English language (hidden link).

The problem arises if I have an "observatory document" not translated into English, in the front-end and also in the list of back-end documents it shows me the linked post in Italian. Instead the strange thing that I have also added some linked posts that are only in English (hidden link) and strangely it shows them to me only in English , does not have the same behavior as those in Italian.

How can I not show the documents in Italian in the post in English? That is, I would like the same behavior that it has for documents in English to have the same behavior for those in Italian, in the front-end I have to see only the documents of the correct language. Can I put an if in the view and filter the loop? Or is there another method? I wish they didn't even show up on the backend list ...

I hope I was clear...

#2471543

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

Thank you for contacting our support forum!

We were able to check that you are using WPML. By chance, in WPML -> Settings -> Post Types Translation, the ‘Observatory document’ post type has the ‘fallback’ option enabled? Screenshot: hidden link

The behavior that you have described is very similar to when this option is enabled. Could you please check it, and if it is indeed active, try to switch to ‘translatable - only show translated items’? I’m afraid that the issue will be solved after this.

Please give it a try and let us know how it goes. Thank you!

Best regards,
Mateus.

#2472217

Hi Mateus,
thanks for the support I was able to solve the problem with the method you indicated to me.
I would like to ask you another question if I can ... I have a view with a loop that generates a list, how can I hide everything if there is a page where it does not find elements?
Let me explain, as you can see here: hidden link the div under the title "Documenti Allegati" is generated by the loop in my view ... in this case it does not find any related post ... I would like to hide the div with class = box-documents when there is nothing how can I do?
Thank you

#2472259

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi there,

Thanks for your reply, and glad that the original problem is solved.

To achieve this, you can wrap the mentioned div in a conditional block, and set it to be hidden if the number of results found is less than 1.

Please check our documentation related: https://toolset.com/course-lesson/using-toolset-conditional-block/

Let me know if this explanation is clear to you and solves the question. Thanks!

#2473451

Hi Mateus,
I can not use the conditional block in my template because I entered the code from php, nothing changes from template I tried ... this is the piece of php code:

<div class="box-documenti">
<h1> <?php echo __('Documenti Allegati', 'dominio-testo-tema') ?></h1>
<div class="box-documenti-wrapper" style="padding-right:30px">
<?php echo do_shortcode('[wpv-post-body view_template="Lista-documenti-Osservatorio"]'); ?>
<div style="clear:both"></div>
</div>
</div>

How can I put a conditional out of view to completely hide this div? It is better to insert it from php because from the view I can only hide the shortcode part.
Can you help me? Thank you

#2473691

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi there,

Thanks for your reply.

Any checking needs to be done in the view itself. We are not able to check outside the view for anything within it since the view is loaded whether or not the data is available or not.

What might work is to use the wpv-conditional shortcode to first test if the field has a value or not before outputting it. So you would need to wrap the whole div contents in wpv-conditional shortcodes if you don't want the label to appear either. The technique is described generally here: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

The specific format to check if a custom field is empty is described here: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

Please check the documentation above and let me know if you can adapt the code using the conditional output. Thanks!