Title: slugs does not include language folder
Last modified: February 2, 2022

---

# slugs does not include language folder

 *  [Juan](https://wordpress.org/support/users/juanmiqueo/)
 * (@juanmiqueo)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/slugs-does-not-include-language-folder/)
 * We have the same setup for all our customers, use a folder for language, default
   language hidden in URL and default home page for language use only language code.
 * We are experiencing some problems :
 * 1/ On menus translated pages permalinks are not including the language prefix
   
   2/ In some cases a loop of redirect on the language page 3/ Its seems the following
   snippet is not taking into account the language preffix if ( function_exists(‘
   icl_object_id’) ) { $page = get_page_by_path( $page_id ); $pageId = $page ? $
   page->ID : null; if ($pageId != null) { $translated_id = icl_object_id( $pageId,‘
   page’ ); if ( $translated_id ) { $page = get_page($translated_id); if ( $page){
   return get_permalink( $page->ID ); // $page->post_name } } } }
 * We thing this is happening since our last update
 * Our setup is:
 * – Multi site wordpress
    – Wp-Ultimo and sunrise to manage custom domains – Polylang
   form language
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fslugs-does-not-include-language-folder%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Thread Starter [Juan](https://wordpress.org/support/users/juanmiqueo/)
 * (@juanmiqueo)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/slugs-does-not-include-language-folder/#post-15320101)
 * Hi!
 * I could find the problem and solve it locally. How can I notify it so it can 
   be solved and deployed
 * In file links-directory.php line 72 on function **add_language_to_link**
 * $root = ( false === strpos( $url, ‘://’ ) ) ? $this->home_relative . $this->root:
   preg_replace( ‘#^https?://#’, ‘://’, $this->home . ‘/’ . $this->root );
 * The last part, $this->home . ‘/’ . $this->root is adding an **extra slash** at
   the end and then the process does not replace the URL including the code
 * We have solved using the following patch but I’m secure you can solve it a better
   way. Added after line 72
 * if (preg_match( ‘/\/\/$/’, $root)) {
    $root = substr( $root, 0, -1 ); }
 * Thanks
 *  [Gui Nery](https://wordpress.org/support/users/guinery/)
 * (@guinery)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/slugs-does-not-include-language-folder/#post-15327866)
 * Hi there! Struggling exactly the same here…
 * Tried to put your code at the line 73, but is doesn’t work:
    if (preg_match( ‘/\/\/
   $/’, $root)) { $root = substr( $root, 0, -1 ); }
 * All my best!
 *  [Benjamin Pongy AXOME](https://wordpress.org/support/users/redpik/)
 * (@redpik)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/slugs-does-not-include-language-folder/#post-15341010)
 * Same bug here.
 *  Thread Starter [Juan](https://wordpress.org/support/users/juanmiqueo/)
 * (@juanmiqueo)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/slugs-does-not-include-language-folder/#post-15341034)
 * Hi [@redpik](https://wordpress.org/support/users/redpik/),
 * Did you try what we did?
 * We make a pull request on the plugin github repository
 * [https://github.com/polylang/polylang/pull/973](https://github.com/polylang/polylang/pull/973)
 *  [Gui Nery](https://wordpress.org/support/users/guinery/)
 * (@guinery)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/slugs-does-not-include-language-folder/#post-15341488)
 * [@juanmiqueo](https://wordpress.org/support/users/juanmiqueo/) have you received
   any answer? And have you fixed your problem?
 * I have the same problem, and even I tried your code, it not works…
 * I imagine since the last plugin update some bug has appeared.
 * I’m struggling that problem of the hidden flags as well as the fact of the slugs
   are not including the language folder…
 *  [Gui Nery](https://wordpress.org/support/users/guinery/)
 * (@guinery)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/slugs-does-not-include-language-folder/#post-15350191)
 * Finally found the problem, and in my case it was not related to “Polylang”, otherwise
   to “Polylang Connect for Elementor”.
 * I have used the “WP Rollback” plugin to get back the 1.0.6 version of the “Polylang
   Connect for Elementor” and everything worked fine.
 * Of course in the perfect scenario the plugin creators should provide a better
   solution. But by now, there is a solution.
 *  Thread Starter [Juan](https://wordpress.org/support/users/juanmiqueo/)
 * (@juanmiqueo)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/slugs-does-not-include-language-folder/#post-15350749)
 * Hi [@guinery](https://wordpress.org/support/users/guinery/),
 * Thank you. I will check it to check if it solves our problem. It’s complicated
   when there are come plugins in our Stack to find the what is failing.
 * Did it affect to Polylang menu?
 * Regards
 *  [Gui Nery](https://wordpress.org/support/users/guinery/)
 * (@guinery)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/slugs-does-not-include-language-folder/#post-15351443)
 * [@juanmiqueo](https://wordpress.org/support/users/juanmiqueo/) I don’t know, 
   but in our case, it worked! 😉

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

The topic ‘slugs does not include language folder’ is closed to new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

 * 8 replies
 * 3 participants
 * Last reply from: [Gui Nery](https://wordpress.org/support/users/guinery/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/slugs-does-not-include-language-folder/#post-15351443)
 * Status: not resolved