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 thread is resolved. Here is a description of the problem and solution.

Problem:
I've got normal wordpress posts with a category in main language. In a template loading these categorized posts like the following loads them just fine.

$args = array(
    'post_type'        => 'post',
    'posts_per_page'   => 24,
    'post_status'      => 'publish',
    'category_name'    => 'Voor & Na foto's',
    'paged'            => $paged
); 
$wp_query = new WP_Query($args);

In attempt to get these same main language posts to load on secondary language page as well I tried setting the WPML "Post Types Translation" settings to not translate Posts (post) and suppressing the filter with `'suppress_filters' => true/false`.
Solution:
Translating the category, setting the slug as category_name and setting suppress_filter to false, does the trick.

This topic contains 4 replies, has 2 voices.

Last updated by dennisv-5 5 months, 1 week ago.

Assigned support staff: Radu.

Author Posts
May 9, 2019 at 10:11 am #3775029

dennisv-5

I've got normal wordpress posts with a category in main language. In a template loading these categorized posts like the following loads them just fine.

$args = array(
    'post_type'        => 'post',
    'posts_per_page'   => 24,
    'post_status'      => 'publish',
    'category_name'    => 'Voor & Na foto's',
    'paged'            => $paged
);

$wp_query = new WP_Query($args);

In attempt to get these same main language posts to load on secondary language page as well I tried setting the WPML "Post Types Translation" settings to not translate Posts (post) and suppressing the filter with `'suppress_filters' => true/false`. Neither seems to work.

Proceedingly I browsed the forums and tried the following solutions as well;

- Setting the WP_Query args `'cat' => ID` instead of 'category_name'
- Setting the 'cat' arg with '$cat = icl_object_id(CAT_ID, "category", false, ICL_LANGUAGE_CODE);'
- Translating the category and setting this as arg 'category_name'
- Translating the category and setting this new category ID as 'cat' arg
- Setting the WPML 'Taxonomies Translation' Categories (category) setting as not translatable

For the sake of sanity I tried with plugins disabled as well.

Nothing seems to work to get the posts.

What else can I try to get the posts of the main language post category?

May 9, 2019 at 12:44 pm #3776225

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Dennis,

Thank you for reaching out the WPML support!

As I understand, you want to display the posts from primary language on the secondary one too. In this case, I think that the option that you're looking for is on Dashboard → WPML → Settings → Post Types Translation. Just simply go to Posts and select the middle column option (Translatable - use translation if available or fallback to default language). This way, the same posts should be displayed on all the languages, when there's no translation for them. Can you give this a try and tell me how it works, please?

Thanks,
Radu

May 9, 2019 at 1:58 pm #3776807

dennisv-5

Hi Radu,

Thank you for catching up with me this swiftly!

As you mentioned just now I tried to set the Post Types Translation "Posts (post)" from not translatable to translatable if available, however regretfully this does not seem to do the trick.

With the post type set as translatable if available, I also tried translating the post category itself again and using this in the WP_Query call, but sadly to no avail. With or without the suppress_filters.

Any other settings or advice I can try?

hidden link
hidden link
hidden link

Kind regards,
Vincent | Appinco

May 13, 2019 at 4:23 am #3795061

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Vincent,

Can you try to use the category slug instead of the actual name, please? According to the WordPress documentation, this should be used instead of the actual name. You can find the slug of the category when editing it on the backend (please see the attached screenshot). Just give this a try and tell me how it does it work this time, please.

Thanks,
Radu

May 13, 2019 at 10:22 am #3796895

dennisv-5

After trying all possible configurations again I've found that by translating the category, setting the slug as category_name and setting suppress_filter to false, does the trick.

It is now loading the posts properly.

My issue is resolved now. Thank you!