WordPress.org

Ready to get started?Download WordPress

Forums

oEmbed auto embed function for custom fields/themes? (3 posts)

  1. lilqhgal
    Member
    Posted 3 years ago #

    I have a custom theme I'm trying get auto embedding YouTube links to work on. They work fine as listed in http://codex.wordpress.org/Embeds 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!

  2. WPBuff
    Member
    Posted 3 years ago #

    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 :-)

  3. learnthat
    Member
    Posted 3 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic