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 8 replies, has 2 voices.

Last updated by Riffaz 4 months ago.

Assigned support staff: Riffaz.

Author Posts
June 2, 2019 at 9:27 am #3937049

davideM-29

Tell us what you are trying to do?

I've a post loop that work with 'cat' => '1990' and when i switch language, the post loop not working.
I saw that category id is different from it to en language, and how i can have the same loop for all language, without change category id ?

<div class="slider">
<ul class="slides">
<?php

$args = array(
'posts_per_page' => $slideshow_number_slider,
'offset' => 0,
'cat' => $slideshow_category,
'orderby' => 'date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'post_mime_type' => '',
'post_parent' => '',
'author' => '',
'author_name' => '',
'post_status' => 'publish',
'suppress_filters' => true,
'fields' => '',
'meta_query' => array(
array(
'key' => '_thumbnail_id',
'compare' => 'EXISTS'
),
)
);

$myposts = get_posts( $args );

foreach ( $myposts as $post ) : setup_postdata( $post ) ;
?>
<li class="slider-item">

<div class="slider-info caption center-align">
<img src="<?php print_r($slider_img_c); ?>" class="responsive-img slot-img" /></div>

<?php endforeach;
wp_reset_postdata();?>

<!-- End List -->
</div>
<!-- End Slider -->

June 2, 2019 at 1:52 pm #3937397

Riffaz
Supporter

Languages: English (English )

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

Hi,

Thank you for contacting WPML support.

Normally, when you switch to the second language the system will look for the translated category for the category you are using in primary language.
So what you are experiencing is normal and expected.

You will have to change the code somehow to make this as you want which is really out of the support scope as it is a custom work.

Anyhow, let me know:

1. how do you get this $slideshow_category ?
- you want to keep this globally in the post loop right?

2. we need a working example of what you are asking about, to check this and look for possibilities.

please,
1. go to hidden link
2. create the post loop as you have it in your site.
3. create only one category
4. configure the WPML as you have it on your site. at the last step just click next (site key)
5. use the post loop
6. check it in the translated page
7. recreate the issue.
8. let us know how to check this and how to recreate this issue.
9. explain the step 8 with screenshots and URLs for better understanding.

Regards,
Riffaz.

June 3, 2019 at 11:53 am #3942027

davideM-29

Hi Riffaz,
1. how do you get this $slideshow_category ?
- This is a variable that i use in backend to set the category id. And the problem was here. Because the loop take the id for the main language, but when i switch to other language, i don't see any result ( because the same category for other lang have different ID ).
Can you tell me how i can get the ID of the category, for different language ?
If the 'slideshow' category in en has id '1944' from this , i need to get the ID for other lang.

2. we need a working example of what you are asking about, to check this and look for possibilities.

- I tryed to setup in link that you provide me, but i need to upload all code files.

June 3, 2019 at 12:10 pm #3942153

Riffaz
Supporter

Languages: English (English )

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

Hi,

1. Thank you for the details.

2. you can upload the code files using the SFTP/SSH details you can find from here:
hidden link

let us know what are the files you will be uploading.

Regards,

June 4, 2019 at 7:56 am #3948917

davideM-29

Hi,
I've uploaded the slideshow code into header.php file. There are some field that i can't get, because it will work only with custom meta on posts.
So if you go on this url :
hidden link
You can found the slider ( class="slider" ) under the header, but if you switch to lang it, you will don't see any slider in the loop. Yesterday i tryed some way, and i saw that if i create new post from it lang and add the image in custom meta box, it will show in IT language, but no slider on EN language. Viceversa if i make new post in EN language, i will see the meta box and slider in EN lang , but i don't see anything in IT lang. Same issue is in this stage website.
Please let me know
Thanks

June 5, 2019 at 11:55 am #3960129

Riffaz
Supporter

Languages: English (English )

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

Hi,

This is really a custom work.

Anyhow, please be patient until our developers check this.
I'll give you the update soon.

Regards,

June 9, 2019 at 6:08 am #3982387

Riffaz
Supporter

Languages: English (English )

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

Hi,

We are moving the staging site to our permanent server.
once it is finished our developers will check this again.
I am updating you the process.
Please be patient until we get back to you again.

Regards,

June 11, 2019 at 6:17 am #3992057

Riffaz
Supporter

Languages: English (English )

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

** updating the status

June 11, 2019 at 12:07 pm #3994935

Riffaz
Supporter

Languages: English (English )

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

Hi,

We Did some tests with the sandbox. hidden link

The issue seems to be related with the hardcoded category.

Please go to WPML > Settings > Taxonomy Translation and set "Categories (category)" as Translatable - use translation if available or fallback to default language.

With this setting, it worked on the sandbox: hidden link

The slider is on the header, before the posts, right?
We added some styles to it just to identify this better.

Let me know how it goes after making the change above.

Regards,
Riffaz.