Title: WPML url patching break valid permalinks
Last modified: February 26, 2025

---

# WPML url patching break valid permalinks

 *  [yanmorinokamca](https://wordpress.org/support/users/yanmorinokamca/)
 * (@yanmorinokamca)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/wpml-url-patching-break-valid-permalinks/)
 * In wp-content/plugins/google-sitemap-generator/class-googlesitemapgeneratorstandardbuilder.
   php, build_posts(), a patch was added trying to fix permalinks with secondary
   languages in WPML. Everything related to $siteLanguages array.
   Our website, have
   a lot of custom permalink filters, and google-sitemap-generator patch results
   in invalid URL listing. The post slug is at the begging and the end of the permalink
   for all secondary language content.Since all our permalinks are already valid
   in english (primary) and french (secondary), i’ve added a $patchUrlLanguage (
   false) condition around both function_exists icl_get_languages/pll_the_languages
   so that $siteLanguages remains empty.Maybe a plugin option or a plugin filter
   could help to activate/deactivate the secondary languages URL patching.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Auctollo](https://wordpress.org/support/users/auctollo/)
 * (@auctollo)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/wpml-url-patching-break-valid-permalinks/#post-18342427)
 * Do you have some example filters that you’re applying?
 *  Thread Starter [yanmorinokamca](https://wordpress.org/support/users/yanmorinokamca/)
 * (@yanmorinokamca)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/wpml-url-patching-break-valid-permalinks/#post-18342568)
 *     ```wp-block-code
       \add_filter('post_type_link', [$this, 'filterCustomPermalinkSlug'], 10, 4);
       ```
   
 * Where filterCustomPermalinkSlug add cache, handle $leavename (3rd argument), 
   get the post type language and works with more than 10 different post types (
   by adding sub-categories for some post type or different prefix). It rewrites
   them from scratch. The function doesn’t handle “page/post” post type, but they
   both work as is with wpml default rewriting.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WPML url patching break valid permalinks’ is closed to new replies.

 * ![](https://ps.w.org/google-sitemap-generator/assets/icon-256x256.png?rev=2713572)
 * [XML Sitemap Generator for Google](https://wordpress.org/plugins/google-sitemap-generator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-sitemap-generator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-sitemap-generator/)
 * [Active Topics](https://wordpress.org/support/plugin/google-sitemap-generator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-sitemap-generator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-sitemap-generator/reviews/)

## Tags

 * [sitemap](https://wordpress.org/support/topic-tag/sitemap/)

 * 2 replies
 * 2 participants
 * Last reply from: [yanmorinokamca](https://wordpress.org/support/users/yanmorinokamca/)
 * Last activity: [1 year, 3 months ago](https://wordpress.org/support/topic/wpml-url-patching-break-valid-permalinks/#post-18342568)
 * Status: not resolved