WordPress.org

Ready to get started?Download WordPress

Forums

OEmbed and Custom FIeld (3 posts)

  1. joehuffman2
    Member
    Posted 4 years ago #

    Is there a way to enact Oembed to show a video from a custom field? Is there a way to wrap the function around the custom field?

  2. lilqhgal
    Member
    Posted 3 years ago #

    I'm interested in this as well. Would like to create a sidebar widget (not widgitized is fine).

  3. learnthat
    Member
    Posted 3 years ago #

    Hi joehuffman2,

    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.

    If you want to put it somewhere else, just change $post->ID to the ID of the post you want to query - for example, if you were going to place it in a sidebar widget. In this example, it should be inside the loop.

    I hope this helps!

Topic Closed

This topic has been closed to new replies.

About this Topic