WordPress oEmbed not working when echoing Vimeo link

I’m creating a film portfolio and I have created the custom post type for portfolio items with a field for the Vimeo link. WordPress is not automatically embedding Vimeo links when I echo the url onto the page and is instead the url is displaying as plain text. I’ve tested by creating a post with the video link and that is auto-embedding just fine. Heres the code I’m using:

    <?php echo get_post_meta(get_the_ID(), 'vimeo_link', TRUE); ?>

Related posts

1 comment

  1. If I’m not mistaken, WordPress doesn’t oEmbed inside of actual theme files. Instead, you’ll need to do something like this

     if (get_post_meta($wp_query->post->ID, 'vimeo_link', true) != '') {
          <iframe src="<?php echo get_post_meta(get_the_ID(), 'vimeo_link', TRUE); ?>?title=0&byline=0&portrait=0" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
     }
    

    if statement reference

Comments are closed.