0

I noticed in one of the updates since wordpress 5 that when I paste in a link to another site it shows the page title as the hyperlink (usually "Home") instead of the URL. I don't want that, I want the actual URL as is.

what I put in the editor

enter image description here

what I get in the visual editor and on the page display:

enter image description here

0

Since v4.4 oEmbed feature was merged into core. This allows users to embed YouTube videos, tweets and many other resources on their sites simply by pasting a URL, which WordPress automatically converts into an embed and provides a live preview in the visual editor.

Option 1

You can remove the oembed functionality by adding this to your functions.php

function disable_embeds_init() {
    remove_shortcode( 'embed' );
    remove_filter( 'the_content', [ $GLOBALS['wp_embed'], 'autoembed' ], 8 );
    remove_filter( 'the_content', [ $GLOBALS['wp_embed'], 'run_shortcode' ], 8 );
    remove_action( 'edit_form_advanced', [ $GLOBALS['wp_embed'], 'maybe_run_ajax_cache' ] );
}
add_action( 'init', 'disable_embeds_init', 9999 );

Source wp-includes/class-wp-embed.php

Option 2

Alternatively you could use the wp_dequeue_script function to remove the wp-embed:

function my_deregister_scripts(){
   wp_dequeue_script( 'wp-embed' );
}
add_action( 'wp_footer', 'my_deregister_scripts' );

Option 3

For a complete oEmbed removal you can use the code below:

function disable_embeds_code_init() {
 remove_action( 'rest_api_init', 'wp_oembed_register_route' );
 add_filter( 'embed_oembed_discover', '__return_false' );
 remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
 remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
 remove_action( 'wp_head', 'wp_oembed_add_host_js' );
 add_filter( 'tiny_mce_plugins', 'disable_embeds_tiny_mce_plugin' );
 add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );
 remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 );
}
add_action( 'init', 'disable_embeds_code_init', 9999 );

function disable_embeds_tiny_mce_plugin($plugins) {
    return array_diff($plugins, array('wpembed'));
}

function disable_embeds_rewrites($rules) {
    foreach($rules as $rule => $rewrite) {
        if(false !== strpos($rewrite, 'embed=true')) {
            unset($rules[$rule]);
        }
    }
    return $rules;
}

Note: code sourced from Disable Embeds plugin

1
  • That's good to know, as it was trying to embed the homepage of the site and throwing lots of errors in the console. – Steve Oct 17 '20 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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