Sticky Links

When you add a regular link to a page or a post, WordPress saves the URL of that page as the link. This means, if the URL changes, the link is broken.

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 permlink 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 permlink of the page you’re linking to. Whenever the URL changes all pages linking to it update immediately and will link to the correct address.

This screen shot shows how internal links look like in the database, once Sticky links are enabled:

Links turned Sticky by WPML

Links turned Sticky by WPML

Your users will never see these “strange” links. Instead, WPML will replace them with the current permlinks when displaying the pages.

Sticky links controls

to enable Sticky links, go to WPML->Sticky links.

Select ‘Enable sticky links‘. Once enabled, WPML will let you batch replace all regular links to sticky links. It will also report any existing broken links and help fix them.

You can always revert this operation by clicking on ‘Revert sticky links to permalinks

10 Responses to “Sticky Links”

  1. Gazouteast says:

    How does this function affect things like users copying links from the page to something like an email?

    If they use right-click copy, or highlight and copy, when they paste the link, will it then revert to the ?p=xyz format, or will it display a page-slug style permalink, or will it show up as a standard browser style URL?

    Has any testing been done to determine this beyond just what is displayed on page on the screen?

  2. Gazouteast says:

    Addendum – I notice the links at the plugin’s wp.org pages in the repository, are using ?p=xyz links. Is this a result of copying from a wpml-enabled website, or was it a deliberate but manual link creation?

    • amir says:

      1. If the user copies the URL from the browser, he’s copying the current permalink. If the user copies the link from the post editor, he would copy the default link. In both cases, it goes to the same page. I prefer the default links, as they are shorter and will always go to the right page.

      2. Links only change to their default format when saving the page from within the WP editor. Then, they change back during display.

      3. Testing for what? In what cases?

      4. In wp.org, we used the default URLs intentionally. This way, if (when) the page slug changes, these links don’t need to change. WordPress will always redirect to the current permalinks.

  3. Gazouteast says:

    1. If the user copies the URL from the browser, he’s copying the current permalink. If the user copies the link from the post editor, he would copy the default link. In both cases, it goes to the same page. I prefer the default links, as they are shorter and will always go to the right page.

    And yet, throughout the documentation for WPML, I see annotations saying to NOT use default link structures but to use custom permalinks – are you saying you’re telling your users to use one method, when you yourself prefer and use another? (?p=xyz is one default link structure within a standard new WP install)

    2. Links only change to their default format when saving the page from within the WP editor. Then, they change back during display.

    On a single language blog, the permalink as displayed at the top of the post or page editor screen, below the post or page title, is how it is saved in the database, and how it displays in the browser, and how it copies from the public pages back into the editor (when cross-linking pages via an anchor tag), or into an email or anything else. As a default method, I never copy from the editor page permalink, always from a published page or post’s url when viewed in the browser …. until using WPML.

    I have never seen the editor page permalink change format between the editor screen, the database, and the browser – ergo, WPML is doing something to the permalinks that is not done when WPML is not present and activated. I say this after years of building sites with WP and many dozens of sites built on many different servers with different operating systems, OS versions, SQL versions etc.

    3. Testing for what? In what cases?

    http://forum.wpml.org/topic.php?id=1452 – refers

    The ONLY site I have witnessed this behaviour on is the single site I have that is using WPML, which is on a server that already has several (single language (English)) WP and WPMU sites built and operating – none of those others exhibit the encoding problem I reported in the forums yesterday (link immediately above this paragraph). That’s the reason I asked the questions in my first comment.

    Now I know you’ll say I am the only user you’ve got who has ever experienced that, which of itself is the reason I came to the WPML forum seeking help, and I know you’ve done exactly what I expect EVERY software developer to do – blame anything and everything else except your own code (many times they are right to do so – if they have case histories to back it up), but the fact I am the first with this issue should give credibility to you assisting and investigating, as it may be an overlooked consequence derived from something you never before considered to be a bug / glitch / problem.

    I am stunned that such a (currently) unique and serious issue is not being taken seriously – I predict you will see a LOT more of this type of error when WP 3.0 rolls and all the inexperienced webmasters begin experimenting with blogs in additional languages from their sub-blogs. I recognise and appreciate that you have a lot on your plate preparing for WP 3.0, but forewarned is forearmed as they say.

    Gaz

    • amir says:

      Have you actually tried it and seen how it works? It’s not as complicated as it looks here and quite a few sites use it just fine.

  4. Gazouteast says:

    I’ve copied my above comment to the linked forum thread – it may be better to continue this discussion there, I didn’t want to hijack the post.

  5. Nardo says:

    Will this also change the URLs correctly when the base WordPress address changes?

  6. Laura S. says:

    I’m using WP 3.0 and WPML 1.8.0 and my admin menu doesn’t have a link to “Sticky Links”. It just has

    WPML
    Languages
    Pro translation
    Support [NEW]

    Moreover, I can’t get the plugin to work. I’ve activated the plugin and added the php code to my header.php file. What’s up with this?

    Thanks,
    Laura S.

Leave a Reply

Please leave here comments about this page only.
For technical support and feature suggestions, head to our forum. We are waiting there!

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Subscribe without commenting