• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Draft / Prevent WordPress Auto Embed

Prevent WordPress Auto Embed

Last updated on October 22, 2018 by Sal Ferrarello

In one of my other posts, Singular vs Plural WordPress Custom Post Type Permalink, I am displaying some URLs on their own line as part of the content.

Screenshot of text with URLs on their own lines.

However, the WordPress oEmbed functionality tries to turn URLs on their own line into a rich content preview (e.g. a YouTube URL alone on a line creates an embedded video). This includes turning a link to a page on another WordPress site into a content preview. This resulted in my post turning http://ferrarello.com/recipes/guacamole into

Screenshot of link to WordPress site displayed as oembed

Original Markup

The original markup I was using (that resulted in the WordPress content preview replacing the URL) was

<pre><code># plural
http://ferrarello.com/recipes/guacamole
    
#singular
http://ferrarello.com/recipe/guacamole
</code></pre>

Corrected Markup

I was able to prevent WordPress from turning the URLs into rich content by wrapping the URLs in <span> HTML tags.

<pre><code># plural
<span>http://ferrarello.com/recipes/guacamole</span>
    
#singular
<span>http://ferrarello.com/recipe/guacamole</span>
</code></pre>
Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Draft, Solution Tagged With: oEmbed, WordPress

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in