Skip Navigation

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

Last updated by Lauren 1 year ago.

Assisted by: Lauren.

Author Posts
November 29, 2023 at 8:08 pm #14956197

jonathanF-3

Hi,
I was looking why we have a lot of redirection in google search console for hidden link.
The website is in french translated to english.

I noticed that some urls have opposite language elements 'site.com/french-post-type/english-title/'. This is true for standard and custom posts.

Exemple: We have a cpt 'produits' with a slug rewrite to 'etiquettes', translated to 'labels' in wpml.

For a post named post-fr translated to post-en, we would get these urls:

The 2 right ones:
site.com/etiquettes/post-fr/
site.com/en/labels/post-en/

but also (all redirected to site.com/etiquettes/post-fr/):

site.com/etiquettes/post-en/
site.com/labels/post-fr/
site.com/labels/post-en/
site.com/produits/post-fr/
site.com/produits/post-en/
site.com/products/post-fr/
site.com/products/post-en/

Same for site.com/en/... redirected to site.com/en/labels/post-en/

I also noticed that in the header(on french website), under industries / last section "etiquettes", we get twice each post. One with the french title and the good url and one with the English title and this url: site.com/labels/french-title/.
On the english side, post are also there in french and english, but always with the right url.

Still in the header, in 'CPT produits' i've made 2 testing posts: 'Test FR' translated to 'Test EN' and 'Test2 FR no translation'.
The settings for the CPT 'produits' is set to 'Translatable – only show translated items' but 'Test2 FR no translation' shows on the english side.

And on standard post single page, in the last section 'Articles that might interest you',
The post-title is sometimes in the wrong language (refresh the page if not), but the url on the title himself is always in the current page language.

Can you help me fix this please?

I've already made a copy of the website with all plugins deactivated except WPML's and ACF pro if you need it.

December 1, 2023 at 2:31 pm #14973697

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-05:00)

Thanks for contacting WPML support. How are you translating the posts from French to English? Also, is this issue only happening on your custom post type? How was the CPT created?

If you would like to share access to your test site, you can provide login details in the next reply which I have marked as private.

December 5, 2023 at 7:36 pm #15002451

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-05:00)

I just checked the site and I"m not seeing the CPTs listed twice under industries in the header, nor when I click through to view the page. Can you please send me the link to the page where you are seeing it as well as a screenshot?

Same thing for the test posts. I'm not seeing them listed anywhere on the page. Please send URL and screenshot.

As for the related articles showing the wrong language, how are you inserting the related articles on the bottom of the post page? Are you using a plugin, custom code, etc?

December 5, 2023 at 8:57 pm #15002703

jonathanF-3

Sorry i didnt mentioned that i made the test post on the staging site, my bad. hidden link.

I can see it on homepage.
We can see both the cpts and the test post in the screenshot.

On the english side the 2 first have the same url. /en/labels/flexible-labels/

On the french side the urls are slightly different, but redirect to same post.
/etiquettes/emballage-flexible/ and /labels/emballage-flexible/.

For the related articles, its custom code:

<section id="others-news">
<h2><?= __('Articles that might interest you', 'multiaction'); ?></h2>
<div id="listes-nouvelles">
<?php
$argsNews = [
'post_type' => 'post',
'posts_per_page' => 2,
'orderby' => 'rand'
];
$arrNews = get_posts($argsNews);

if ($arrNews) :
foreach ($arrNews as $news):
$category = wp_get_post_terms($news->ID, 'category', array("fields" => "all"));
$newsImg = get_field('thumb_copie', $news->ID);
$catColorAutres = get_field('couleur_categorie', 'term_' . $category[0]->term_id);
?>
<div class="news">
<div class="img-wrap">
<img src="<?= $newsImg['url'] ?>" />
</div>
<div class="content">
?c=term_id ?>" class="category ">name; ?>
ID) ?>" class="permalink">

ID) ?>


<div class="bg"></div>
</div>
ID) ?>" class="permalink">
</div>
<?php
endforeach;
endif;
wp_reset_postdata();
?>
</div>
</section>

Thank you!

header-labels-cpts.jpg
December 5, 2023 at 9:44 pm #15003003

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-05:00)

Thanks for clarifying where you are seeing this, and the screenshot. I looked at your menus, but I don't see Industries as part of the menu. How are you adding this content to the menu?

As for the related links, custom code work is outside the scope of WPML Support, but here's a link to our available API hooks. You'll need to add something to display only respective languages. Your translated category will have a different ID, so perhaps you can pull the ID of the tranlsated category and display only posts in a certain language. Here's our library of hooks: https://wpml.org/documentation/support/wpml-coding-api/

December 6, 2023 at 4:49 pm #15010641

jonathanF-3

The menus are also custom coded so i looked into it.

You were right when you said to add something to display only respective languages.

It was the same problem at both places.

The query was made with get_posts() and i just added 'suppress_filters' => false to the arguments to solve the problems.

Thanks for your help!