WPML Sticky Links Addon prevents links between pages and posts from ever breaking, even if pages move and get renamed.
WordPress makes it all too easy to change page addresses, causing all incoming links to go broke (404 error). Here are a few ways to do that:
- Change the page’s parent
- Change the slug
- Change the site’s permalink structure
WPML prevents changes in URLs from breaking incoming links. When you create a link, WPML automatically makes it Sticky. Instead of storing the URL of that page (at the time the link was created), it stores the page number. This can never change, no matter what you do. Then, when the page is displayed, WPML inserts the permalink of the page you are linking to. Whenever the URL changes all pages linking to it update immediately and will link to the correct address. The following screenshots show how internal links look like in the database, once Sticky Links are enabled. Your users will never see these “strange” links. Instead, WPML will replace them with the current permalinks when displaying the pages.
Sticky links controls
Once you enable the Sticky Links module, you can control what strings it handles. To do this, go to the WPML -> Sticky links page. By default, WPML will turn all links in post body to sticky. You can also turn links in widgets and strings to sticky. WPML will let you batch replace all regular links to sticky links. It will also report any existing broken links and help fix them. If you have enabled Sticky Links after creating some content, links in that existing content are not immediately turned into Sticky. The Sticky Links admin screen tells you how much content may include normal (not Sticky) links. WPML can scan that content and convert all links to Sticky. Click on the Scan button to do that. You can always return your links to regular (not Sticky) by clicking on Revert sticky URLs to permalinks.
Linking to pages in a different language
Sometimes, you might want to insert a link to a page that is in another language. Since Sticky Links adjusts the links automatically, it might prevent you from doing this and adjust the link to point to the same language instead. To be able to add links to pages in other languages, you need to add the following filter to your theme’s functions.php file. In the above code, use the $blacklist array to specify all the URL slugs for the pages in the original languages that you want to link to. In our example, we want to link to English version of “Documentation” (slug “documentation”) and “Page Builders” (slug “page-builders”) pages, so we use the following two lines: