Disable Auto-Embedding of Links in WordPress Content Easily
How to disable auto embed in wordpress;
Stop wordpress from embedding links automatically;
Prevent automatic link embedding wordpress;
Wordpress turn off auto embed feature;
Disable embeds for specific urls in wordpress;
Wordpress stop auto embedding links;
How to prevent wordpress from embedding urls;
Wordpress disable automatic embeds;
Turn off link embedding in wordpress;
Stop wordpress auto embed links;
Explanation
If you're tired of WordPress automatically turning your plain URLs into embedded content, this little tweak is your friend. By using this code, you can stop WordPress from doing its auto-embed magic.
Here's what it does:
- It defines a function that removes the part of WordPress responsible for auto-embedding links.
- This function is then hooked into WordPress's initialization process, ensuring it runs early on when your site loads.
Once this code is in place, WordPress will no longer automatically convert URLs into embedded content like videos or tweets. Instead, your URLs will stay as simple links, just as you typed them.
Code
<?php
// Function to disable WordPress auto-embeds
function wp_dudecom_disable_auto_embeds() {
// Remove the auto-embed filter from the content
remove_filter('the_content', array($GLOBALS['wp_embed'], 'autoembed'), 8);
}
// Hook the function to the 'init' action
add_action('init', 'wp_dudecom_disable_auto_embeds');
?>
Instructions
File Location: Add the code to your theme's functions.php
file or a custom plugin file.
Prerequisites:
- Access to your WordPress site's file system (via FTP or a file manager).
- Basic understanding of how to edit PHP files.
Implementation Steps:
- Backup your site: Before making any changes, ensure you have a backup of your site. This is a precautionary step to prevent data loss.
- Access your WordPress files: Use an FTP client or your hosting provider's file manager to access your WordPress installation files.
- Navigate to your theme's directory: Go to
wp-content/themes/your-active-theme/
and locate thefunctions.php
file. - Edit the functions.php file: Open the
functions.php
file in a text editor. - Add the code: Copy and paste the provided code snippet at the end of the
functions.php
file. - Save the changes: After adding the code, save the
functions.php
file. - Test your site: Visit your site and check if URLs are no longer auto-embedded. They should now appear as plain text links.
If you encounter any issues or need further assistance, consider reaching out to wp-dude.com for professional help with WordPress implementation or advanced functionality.