OEmbed and Custom FIeld (3 posts)

  1. joehuffman2
    Posted 6 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
    Posted 5 years ago #

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

  3. learnthat
    Posted 5 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