Skip Navigation

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

Problem:
If you're experiencing issues with Sticky Links converting URLs to PageIDs and you want to retain the original URL for specific links, you may find that the suggested code to blacklist certain slugs is not working as expected.

Solution:
We recommend adding the following code to your

functions.php

file to blacklist specific requests and prevent Sticky Links from converting them into PageIDs. Here's the code you should use:

add_filter( 'wpml_sl_blacklist_requests', 'wpml_sl_blacklist_requests', 10, 2 );

function wpml_sl_blacklist_requests( $blacklist, $sitepress ) {
    $blacklist[] = 'your-page-slug';
    return $blacklist;
}

After adding this code, re-add the link to the page and save it. This should exclude the specified slug from being converted by Sticky Links.

More info on next link: https://wpml.org/documentation/getting-started-guide/sticky-links/#linking-to-pages-in-a-different-language

If this solution doesn't look relevant to your issue, please don't hesitate to open a new support ticket. You can do so by visiting the WPML support forum.

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 9 replies, has 2 voices.

Last updated by Dražen Duvnjak 5 months, 3 weeks ago.

Assisted by: Dražen Duvnjak.

Author Posts
November 2, 2023 at 8:35 am #14713315

jerisscloudcenter

Hello, I am using Sticky Links which converts URLs to "PageIDs" (and I'm happy about it) but on SOME LINKS only, I'd like to retain the original URL (not converted). How can I do that?

November 2, 2023 at 10:35 am #14715203

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

thanks for your patience.

I have checked the URLs you shared in the chat, but I do not see the same behavior.

Anyway for us to check further and for an easier understanding of the issue and excluding any custom code you may have, I have created a test site.

- hidden link

Please login and create one example page or URL, and explain what happens and what would be the correct behavior.

Then I will check further and consult with our 2nd tier.

Thanks,
Drazen

November 2, 2023 at 6:57 pm #14720607

jerisscloudcenter

I don't need any testing. I just want an answer to my question. If Sticky Links automatically updates all links from URLs to PageIDs, is there any way to prevent Sticky Links from transforming only CERTAIN URLs ? That's all I'm asking for. I want to AVOID Sticky Links transforming certain URLs that I want to specify.

November 3, 2023 at 6:47 am #14722603

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

there is no way out of the box to disable sticky links on some content.

As for how the sticky link works, it will never show on the front end as hidden link, this is only shown in the backend and in the front end it shows as your permalink settings. As for redirection, redirecting from page ID permalink to your current permalink happens also without WPML, it is done by WP and that is expected and how WP works.

Video: hidden link

In your case, there might be also some other things or code involved that are causing issues or problems for you specifically with sticky links. I would advise checking in minimal.

Feel free to contact us again if there is anything else we can do for you.

Regards,
Drazen

November 6, 2023 at 7:38 am #14735039

jerisscloudcenter

On the live chat, your colleague told me that the below code should "blacklist" the listed slugs to prevent Sticky Links from transforming this slug into Page ID. But it doesn't work. Why this code doesn't work? Please check it and tell me why it doesn't work.

https://wpml.org/documentation/getting-started-guide/sticky-links/#linking-to-pages-in-a-different-language

add_filter( 'wpml_sl_blacklist_requests', 'wpml_sl_blacklist_requests', 10, 2 );

function wpml_sl_blacklist_requests( $blacklist, $sitepress ) {
$blacklist[] = 'mon-compte';
return $blacklist;
}

November 6, 2023 at 8:06 am #14735237

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

my colleague said that you can try this if it helps, and that it might help, but that code is not used for that nor maintaining or converting URLs of pages.

Code is used to exclude auto connection /conversion of links from 1st to 2nd language, and this way, with code, you can set different URLs, external ones. It works only for links inside page content.

As it says in docs:

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.

Regards,
Drazen

November 6, 2023 at 8:08 am #14735273

jerisscloudcenter

Hello,

But seriously I need a way to exclude a "slug" from being auto converted from URL to PageID. Why can't you give us a shortcode to do that? Seriously I'm paying so much money every year for this WPML. I'm asking just a small thing, a small shortcode for your Sticky Links to exclude some slugs from auto-converting them from URL to PageID.

Please figure out a way.
Thanks

November 6, 2023 at 8:14 am #14735281

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

as I already said, in order for us to try to help and understand in which cases it happens and what you are trying to do, we need some help and collaboration from your side. What you are describing, might not be directly related to sticky links and WPML, but WordPress, as sticky links, do not convert URLs on front end, but only back end.

So, please in order to continue, follow my suggestion and try to reproduce and show us an example on the next test website, without any additional custom code or plugins, simple example:

- hidden link

We will be glad to check and try to further help.

Regards,
Drazen

November 6, 2023 at 8:27 am #14735383

jerisscloudcenter

I just reproduced the issue on your sandbox.

I created a new WooCommerce EndPoint :
hidden link

Then when I create a URL Link towards this EndPoint, after page save, this becomes
/?page_id=62

I don't want that, because it will go to the default My Account tab instead of going to the EndPoint. I want to keep the entire URL by excluding the "my-account" slug from Sticky Links.

November 6, 2023 at 9:37 am #14736115

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

great, thanks for taking the time to reproduce. It makes now a lot more sense to me, and the situation is clear.

I have added the next code to functions.php, and then re-added the link to the page and saved the page. It seems to work fine now. Please check.

add_filter( 'wpml_sl_blacklist_requests', 'wpml_sl_blacklist_requests', 10, 2 );
 
function wpml_sl_blacklist_requests( $blacklist, $sitepress ) {
    $blacklist[] = 'my-account/custom-endpoint-183927';
    return $blacklist;
}

- hidden link

Regards,
Drazen

November 6, 2023 at 9:46 am #14736137

jerisscloudcenter

Perfect ! Thanks !

jerisscloudcenter confirmed that the issue was resolved on 2023-11-06 09:46:55.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.