2

There are several posts about this, - but I suspect that it has changed after Gutenberg, since I can't get either of the methods to work.

I'm trying to stop WordPress embedding links, when written in a post. I just want the regular link to display... Nice and blue as always. But it converts it to an Embed URL-object.

Attempt 1) I've tried:

function WPSE_dequeue_scripts(){
    wp_deregister_script('wp-embed');
}
add_action( 'wp_enqueue_scripts', 'WPSE_dequeue_scripts' );

Didn't work. I can still see the wp-embed.min.js being loaded in the network-developer tab:

wp-embed.min.js in network tab

Attempt 2) I've also tried:

function WPSE_remove_shiftnav_assets(){
    remove_action( 'wp_enqueue_scripts' , 'wp-embed' , 9999 );
}
add_action( 'wp' , 'remove_shiftnav_assets' );

Even though I would strongly prefer something in my functions.php-file to remove this, then I've also tried this plugin here without any result either.

How do I stop it from auto-converting links to that Embed URL?

5
  • Dequeuing it isn't enough, the order the hooks run in matters, e.g. if you attempt to dequeue it before it's enqueued it won't work ( a bit like closing a door before it's opened, it doesn't do anything, or opening an open box, it doesn't make much sense ). So you did the correct thing, on the correct hook, but you didn't account for "when" you did it
    – Tom J Nowell
    Jun 8, 2019 at 14:50
  • Also, did none of the solutions you linked to work? I don't see dequeuing wp-embed in that article, and I'm not sure it will do what you hope it will do either
    – Tom J Nowell
    Jun 8, 2019 at 14:52
  • Thanks for weighing in. So how do I figure out which hook to dequeue it on? I tried all kinds of things (several other things, than I mentioned in the question), but without any results. The mentioned attempts are the best attempts, though.
    – Zeth
    Jun 8, 2019 at 18:03
  • You're already using the right hook, the problem is not where you do it, it's when, but I'm not sure that it'll do what you want it to do if you manage to dequeue it anyway. Those solutions you linked to assume the classic editor, wp-embed is just a library for displaying embeds, it isn't the part of the block editor that changes URLs into embeds
    – Tom J Nowell
    Jun 8, 2019 at 23:55
  • tutorial with code here: kinsta.com/knowledgebase/disable-embeds-wordpress
    – majick
    Jun 9, 2019 at 22:49

1 Answer 1

0

The quickfix: Copy the link into a text-editor and add a space before it. And then copy that new text (with the prefixed space) into whereever you want it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.