Support » Fixing WordPress » oEmbed auto embed function for custom fields/themes?

  • I have a custom theme I’m trying get auto embedding YouTube links to work on. They work fine as listed in by placing the URL on a single line with space above and below, but that’s not what I want to do. Is there a function I can grab or some other snippet of code so that I can place this elsewhere in my custom theme? Ideally I’d like to create a little sidebar widget and when the user enters their YouTube link into a custom field I’ve setup (my_custom_video_field), I’d like it to work as if it was in the regular position. Is this possible? Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Very interested in this functionality. As a matter of fact, with the right hint of where to look, I could probably hack something together for everyone else to use. Hard to believe that such functionality does not exist yet 🙂

    Hi lilqhgal,

    I wanted the same thing and achieve it using this code in my single.php file:

    <?php echo wp_oembed_get( get_post_meta($post->ID, "videourlcustom", true) ); ?>

    In the example, videourlcustom is the name of the custom field which contains the URL for what you want to embed.

    I hope this helps!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘oEmbed auto embed function for custom fields/themes?’ is closed to new replies.