Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I got this code to show video loops on my blog. It's working nicely.

Function.php

function catch_video() {
  global $post, $posts;
  $first_vid = '';
  ob_start();
  ob_end_clean();
  $output = preg_match_all('/<iframe.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
  $first_vid = $matches [1] [0];
  echo '<iframe width="100%" height="400" src="';
  echo $first_vid;
  echo '" frameborder="0" allowfullscreen></iframe>';
}

It is shown by the code in the loop: <?php catch_video();?>

Now, I would like that when it was posted a featured image instead of the video, it showed a code of mouse hover (I already have it ready), so I created this code but something is wrong with it:

<?php $blog = new WP_Query($args); ?>
<?php while( have_posts() ): the_post(); ?>

   <?php if(has_post_thumbnail()): ?>

   <!-- Hover Image -->
     <div class="image-wrapper-hover">
        <!-- hover-content -->
        <?php the_post_thumbnail('large');?>
     </div>
   <!-- close Hover Image -->   

   <?php else ?>

      <?php catch_video();?>

   <?php endif ?>

Anyone knows what is wrong?

share|improve this question
3  
What problem are you having? Are you getting any errors? –  Joseph Jan 22 '13 at 2:24

1 Answer 1

up vote 0 down vote accepted

At first blush, it appears that you are missing a colon from your else statement. Without more info, though, I cannot tell you anything else.

<?php if( has_post_thumbnail() ) : ?>

    <div class="image-wrapper-hover">
        <?php the_post_thumbnail( 'large' ); ?>
    </div>

<?php else : ?>

    <?php catch_video();?>

<?php endif; ?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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