Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem: Custom Post Type slug translation is not working

Solution: It is happening because of a conflict with the latest version of String Translation and *Use different slugs in different languages* feature. Our developers have fixed the problem and this fix will be included in WPML String Translation 2.8.0 version. So for the time being please try the following steps as a workaround.

1) Please go to *wpml-string-translation/classes/slug-translation/* folder
2) Open *class-wpml-slug-translation.php* file for edit
3) Scroll down to line 249(function filter_pre_get_posts)
4) Add the following code at the top of the function filter_pre_get_posts

if ( ! empty( $query->query_vars['p'] ) ) {
    return $query;
}

5) Save the changes and make sure you are getting the expected result for slug translation or not

Relevant Documentation:

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.

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Puntorosso 2 years, 6 months ago.

Assigned support staff: Bigul.

Author Posts
February 21, 2018 at 1:14 am #1524326

Puntorosso

Hi, if you look at this german page

hidden link

and switch to the swiss language you'll get a 404.

The problem is that this page is a WPML duplicate of the german version, so I cannot find the cause of this error.

Any idea?

Thanks

February 21, 2018 at 6:16 pm #1525301

Bigul
Supporter

Languages: English (English )

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

Hi Puntorosso,

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

Please try the following steps and check the issue is existing or not

1) Visit WPML>>Languages
2) Update the *Language URL format* settings(just resave)
3) Visit Settings>>Permalinks
4) Update the permalinks settings(just resave)
5) Then make sure the issue is existing or not

Is it only happening in this Post? Are you able to reproduce with other existing Swiss posts or a newly created post?

--
Thanks!

Bigul

February 21, 2018 at 9:29 pm #1525498

Puntorosso

Hi, sadly it didn't worked.
I did also the typical WPML troubleshooting routines but that didn't helped neither.
It looks like all swiss "location" custom posts are 404s.

By the way, the custom post is created using Types.

Thanks

February 22, 2018 at 2:22 pm #1526292

Bigul
Supporter

Languages: English (English )

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

Hi Puntorosso,

Thank you for the updates. Please let me know the following for tracking the issue.

1) Please create a new Post in German, translate or duplicate it to Swiss and check the bug is existing for you or not

2) Have you translated the slugs of *location* custom post type before?

3) Please share with me the WordPress debug.log (not WPML debug information). Please check this page for instructions https://wpml.org/documentation/support/debugging-wpml/

To enable it, open your wp-config.php file and look for define(‘WP_DEBUG’, false);. Change it to:

// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
 
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
 
// Disable display of errors and warnings 
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define( 'SCRIPT_DEBUG', true );

In this case, the errors will be saved to a debug.log log file inside the */wp-content/* directory. Please do the steps to reproduce the bug and check you are getting any errors or warning related to WPML in the log file.

If you can paste your debug.log to http://pastebin.com/index.php and provide me that link it would be great! (This is the cleanest way because sometimes the logs are long and create a complete mess of discussion).

--
Thanks!

Bigul

February 22, 2018 at 7:18 pm #1526684

Puntorosso

Hi,

1) same error.

2) "location" is translated in 3 other languages (.de, .it, .es) and they all work without problem.

3) https://pastebin.com/ZZPYmfTN

The problem is that I don't see any new entry on the debug.log, neither in the error_log.txt which is pasted here

https://pastebin.com/4Dk1iufZ

Thanks a lot for your help.

February 23, 2018 at 2:44 pm #1527645

Bigul
Supporter

Languages: English (English )

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

Hi Puntorosso,

Thank you for details. Please try the following steps after a backup and make sure the bug is existing for not.

1) Go to WPML>>Support page
2) Click on Troubleshooting link (blue link at the bottom of page)
3) In Troubleshooting page, please click on the following options of *Clean up* section. Wait for confirmation of processing after each one.

- Clear the cache in WPML
- Remove ghost entries from the translation tables
- Fix element_type collation
- Set language information
- Assign translation status to duplicated content
- Fix terms count
- Fix post type assignment

4) Visit WPML>>Languages
5) Update the *Language URL format* settings(just resave)
6) Visit Settings>>Permalinks
7) Update the permalinks settings(just resave)

If you are still having the issues, please fill the private details fields after a full site backup. Check the following links for more details about our private information sharing. I would like to access admin area of your site for further checking.

hidden link

https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

--
Thanks!

Bigul

February 26, 2018 at 5:34 pm #1529573

Bigul
Supporter

Languages: English (English )

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

Hi Puntorosso,

Thank you for the login information. The Swiss posts are showing the correct result after I turn off the slug translation. Please check the attached images for more details and let me know your feedback.

Maybe it is happening because you have enabled the slug translation for *location* and using the same slug for all the languages. We have a known about this and the fix will be included in WPML String Translation 2.8.0(but the release date is not fixed) yet.

I have a request. Please open a new ticket for the following issue. Because it sounds like a different issue. As per our support policies we can only handle one issue per ticket. It will help us to avoid multiple issues in a single thread. You can assign the new ticket to me by mentioning my name in the new ticket. Thank you for the understanding.

I get "error" or "HTTP/2.0 500" when I press "Assign translation status to duplicated content"

--
Thanks!

Bigul

February 27, 2018 at 11:18 am #1530352

Puntorosso

Ok, lets wait for the 2.8 then. Thanks a lot for your help.