0

I have 2 choices on the edit post page to insert an video ID from either vimeo or youtube. The user needs to select, with a select field (channel), if he wants to embed video from one or the other.

<?php if (get_field('channel') == 'Youtube') {
        echo get_field('youtube_video_id');
    }
    if (get_field('channel') == 'Vimeo') {
        echo get_field('vimeo_video_id');
    }
?>

Now I'd like this to overrule the_post_thumbnail. So when a video is posted is shows the video instead of the thumb. Is that possible?

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php if ( has_post_thumbnail()) : ?>
    <?php the_post_thumbnail(); ?>

    *** MAGIC HERE I GUESS? ***

    <?php endif; ?>
<?php endwhile; else: ?>
    <p>Nothing here</p>    
<?php endif; ?>

Hope somebody can push me in the right direction. Or am I doing this the other way arround? I'm my PHP is still a learning curve.

Thanks, /Paul

1 Answer 1

0

I think all you need is this:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  if (get_field('channel') == 'Youtube') {
    echo get_field('youtube_video_id');
  } elseif (get_field('channel') == 'Vimeo') {
    echo get_field('vimeo_video_id');
  } elseif ( has_post_thumbnail()) {
    the_post_thumbnail();
  }

That should use a Youtube video, then a Vimeo video, then the thumbnail, and do nothing otherwise.

1
  • ah thanks, I'm on my phone atm, will check tomorrow and accept.
    – Kortschot
    Commented Jul 8, 2013 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.