This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 3 replies, has 2 voices.

Last updated by Bigul 5 months, 2 weeks ago.

Assigned support staff: Bigul.

Author Posts
April 29, 2019 at 2:16 am #3699389

stephanieM-9

We have about 300 blogs set up in default language.
For second language: we use the "translation if available or fallback to default language" for posts which works fine.

Now we need exclude some posts (only a few) from second language which are currently have the fallback content from default language.

April 29, 2019 at 6:17 pm #3705985

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Welcome to the WPML support forum. I will do my best to help you to resolve these issues.

It sounds like a custom requirement. Therefore can you please share more about the workflow of the following requirement.

Now we need exclude some posts (only a few) from second language which are currently have the fallback content from default language.

To help you faster, I've enabled debug information for this support ticket. Please see this link for how to get this information from your site and give it to us: http://wpml.org/faq/provide-debug-information-faster-support/

--
Thanks!

Bigul

April 29, 2019 at 11:30 pm #3706923

stephanieM-9

Hi there,

Please find the attached images for our WPML setting for posts.

1. We have about 300 posts created in default language.

2. All the posts showed under second language use the content fallback to default language.

3. We want to exclude some posts under second language because offer is open users visit the site for in default language.

4. Possible solution: Update the posts translation setting from "Translatable - use translation if available or fallback to default language" to "Translatable - only show translated items". However, duplicating content of 300 + posts is a lot of work. And it is waste of database resources.

Is there other ways like setting up some filter to exclude/hide those posts under second language?

April 30, 2019 at 4:35 pm #3713639

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Thank you for the updates. I have checked about this issue with our team. Sorry, there are limitations to achieve this requirement.

It is partially working after the following steps. But the posts will be listed on the secondary language Blog page and it will direct to *404* page.

1) Translate the post to secondary language(Just overwrite with original language contents)
2) Set the translated post as Draft
3) Then add the following code in functions.php of the theme to hide it from WPML language switcher

add_filter( 'icl_ls_languages', function( $langs ) {
    foreach ( $langs as $code => $lang ) {
        if ( in_array( get_post_status( $lang['id'] ), array( 'draft', 'auto-draft' ) ) ) {
            unset( $langs[ $code ] );
        }
    }
    return $langs;
} );

Therefore it seems that for now, you need custom programming work to achieve this requirement which is beyond the scope of our support. We don't have a hook or filter to achieve this task.

So at this point, I would like to suggest you consider contacting one of our certified partners from this link http://wpml.org/documentation/support/wpml-contractors/ for this requirement. Thank you for your understanding.

--
Thanks!

Bigul