Stop Turning Pasted URLs Into Embeds
Keeps links pasted on their own line as plain links instead of turning them into embedded videos, tweets or posts.
Opens WPIDE on
Code
add_action( 'init', function () {
global $wp_embed;
if ( $wp_embed instanceof WP_Embed ) {
remove_filter( 'the_content', array( $wp_embed, 'autoembed' ), 8 );
remove_filter( 'widget_text_content', array( $wp_embed, 'autoembed' ), 8 );
remove_filter( 'widget_block_content', array( $wp_embed, 'autoembed' ), 8 );
}
} );
Notes
Embed blocks added on purpose in the block editor still work.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.