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.

Our next available supporter will start replying to tickets in about 7.62 hours from now. Thank you for your understanding.

This topic contains 10 replies, has 3 voices.

Last updated by PureReturn 1 year, 5 months ago.

Assigned support staff: Bigul.

Author Posts
April 5, 2018 at 9:30 am #1565714

timK-2

Hi Bigul

Short update.

- After having translated all categories to German the problem with the category pages is solved.

- I still have problems with the author pages. That's the main problem right now. As i said it seems that it has something to do with YOAST SEO.

- I have 5 pages on the german page where I copied the english content. How can I change the Hreflang Code from german to english?

Thank you

Tim

April 5, 2018 at 4:02 pm #1566265

Bigul
Supporter

Languages: English (English )

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

Hi Tim,

For your kind information, I checked the following requirement with my team. It sounds like a custom requirement and need some coding.

I have 5 pages on the german page where I copied the english content. How can I change the Hreflang Code from german to english?

Are you trying to list only English *hreflang* for these German pages? Please explain little more about the requirement for a better understanding.

The following filter will help us to add custom *hreflang* for the post and pages. Please add it in *functions.php* of your theme and check you are getting the expected result or not.

add_filter('wpml_alternate_hreflang', 'change_page_hreflang', 10, 2);
function change_page_hreflang($url, $lang_code) {
      
    if($lang_code == apply_filters('wpml_default_language', NULL )) {
          
        echo '<link rel="alternate" href="' . $url . '" hreflang="en-us" />';
    }
      
    return $url;
}

--
Thanks!

Bigul

April 16, 2018 at 11:29 am #1644030

timK-2

Hi Bigul

I have added the code.

I have 5 posts that are written in English and originally published on my English page. As I regularly update these posts I don't want to translate them to german but just copy the english content so that both the english and "german" version gets updated whenever I change the english post.

For example:

1. hidden link
2. hidden link

Thanks

Tim

April 17, 2018 at 12:50 pm #1661346

Bigul
Supporter

Languages: English (English )

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

Hi Tim,

Thank you for the updates. The best option to achieve this functionality will be you can choose *Translatable – use translation if available or fallback to the original language* option as translation preferences for *Posts* post type. This feature will help you to show the default language content in the secondary language without translating or duplicating the Posts/Pages. Please check the following documentation for more details and let me know your feedback.

hidden link

https://wpml.org/documentation/translating-your-contents/displaying-untranslated-content-on-pages-in-secondary-languages/

--
Thanks!

Bigul

April 17, 2018 at 2:13 pm #1662494

timK-2

Thank you Bigul. This problem is solved!

Now there are 12 errors left. Attached I send you a screenshot with further information.

Thank you

Tim

April 18, 2018 at 12:39 pm #1673789

Bigul
Supporter

Languages: English (English )

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

Hi Tim,

Thank you for the feedback. It may be happening because you have submitted old XML Sitemap for the Categories. Or maybe it will take a timeframe to refresh the Sitemap file according to the current values.

For an example, the category term *Vietnam* don't have a parent term now. In the error notice data, it is showing *Asia* as parent term for *Vietnam*.

Please check the attached images for more details and let me know your feedback.

--
Thanks!

Bigul

April 18, 2018 at 5:54 pm #1678787

timK-2

Hi Bigul

I also have some problems with my sitemaops "Sitemap.xml file has format errors". I have some empty lines as you can see here:

hidden link
hidden link

I found this thread in your forum:

https://wpml.org/forums/topic/yoast-seo-and-blank-line-inside-sitemap/

I have recently deleted the spanish and french version of my blog. I am however not sure if I did it correctly and if I have really deleted 100%.

Maybe that's the problem? Semrush also complains about 1 broken link to a french sitemap which should not exist anymore: hidden link

Could you check if I deleted the french and spanish version correctly?

Thank you so much

Tim

April 18, 2018 at 5:57 pm #1678799

timK-2

I have just found a table that shows inactive content and compared it with the sitemaps. It seems that each page/ post is one empty line in my sitemap.

Inactive content
In order to edit or delete these you need to activate the corresponding language first

Language Posts Pages Categories Tags
Total 4 25 0 3

UPDATE:

I have just deleted all remain french/ spanish content. No more empty lines in the sitemaps. I will do another test with semrush and will update you.

April 18, 2018 at 6:56 pm #1679060
timK-2

Hi Bigul

The problem with the sitemaps is solved.

However I am having a 2 problems now ... seems to be a never ending story.

1. When you open my blog page: hidden link and try to click at the bottom of the page on "2" or "next" you won't get directed to page 2 but only refresh the first page.

2. There is again a problem with the author pages.

- hidden link looks okay, only problem is that not only posts written by katie are shown but all posts

- hidden link & hidden link no headings and introduction anymore. Also all posts are shown

Above problems do not occur when I deactivate WPML plugin.

The second problem also generates hreflang conflicts 🙁

Any ideas what's wrong now?

Thank you

Tim

New threads created by Bigul and linked to this one are listed below:

https://wpml.org/forums/topic/pagination-is-not-working-in-blog-page/

April 19, 2018 at 5:50 pm #1699779

Bigul
Supporter

Languages: English (English )

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

Hi Tim,

Thank you for the feedback. Happy to know the sitemap issues are fixed now.

Please close this thread and open a new ticket for the *Author Pages issues*. Because as per our support policies, we can only handle one issue per ticket. You can assign the new ticket to me by mentioning my name on it. It will help us to serve you better and we can avoid discussing multiple problems in one ticket. Thank you for the understanding.

--
Thanks!

Bigul

September 6, 2018 at 12:36 pm #2710699

PureReturn

Your hreflang function works nicely but is it possible to force it to insert it at the end as it currently adds the x-default at the top of the list?

add_filter('wpml_alternate_hreflang', 'change_page_hreflang', 10, 2);
function change_page_hreflang($url, $lang_code) {
       
    if($lang_code == apply_filters('wpml_default_language', NULL )) {
           
        echo '<link rel="alternate" href="' . $url . '" hreflang="en-us" />';
    }
       
    return $url;
}