Support » Plugin: Featured Video » Problem with featured video/image

  • Hello there,

    I’d like to use the featured video plug-in to display a video in a post, but when there is no video the featured image should be displayed.

    My current code looks like this:

    <!-- Featured Image -->
    			<?php if(get_option_tree('show_featured_image') == 'Yes') : ?>
    					<?php if (has_post_video()) the_post_video(640,360) ?>
    					<?php if (has_post_thumbnail( $post->ID )) {
    						// Check for Sencha preferences, set the variable if the user wants it.
    						// Unused as of 1.04 for the time being until some bugs get sorted out
    				 		if (get_option_tree('sencha') == 'Yes') {
    							$sencha = '';
    						} else {
    							$sencha = '';
    						// Grab the URL for the thumbnail (featured image)
    						$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
    						$post_slug = str_replace(" ", "-",$post->post_name);
    						// Check for a lightbox link, if it exists, use that as the value.
    						// If it doesn't, use the featured image URL from above.
    						if(get_custom_field('lightbox_link')) {
    							$lightbox_link = get_custom_field('lightbox_link');
    						} else {
    							$lightbox_link = $image[0];
    					<!-- <a href="<?php echo $lightbox_link; ?>" data-rel="prettyPhoto[<?php echo $post_slug; ?>]"> -->
    						<img class="aligncenter" src="<?php echo $sencha; ?><?php echo $image[0]; ?>" alt="<?php the_title(); ?>" />
    					<!-- </a> -->
    				<br class="clearfix" />
    				<?php } else {} ?>	 
    			<?php endif; ?>

    But it displays both the featured video and featured image. I’ve tried but I can’t seem to get it the code working to;

    1. Display a video if there is an URL for the featured video entered in the post in WordPress.
    2. Display the featured image if there is NO link entered for a featured video.

    I only seem to get both to be displayed working. Anybody go a solution for this?


Viewing 1 replies (of 1 total)
  • Hey Aandagt,
    have a look at Featured Video Plus . It does exactly what you request here automatically if your theme uses the_post_thumbnail() or get_the_post_thumbnail() to display featured images. I wrote it after using the original Featured Video plugin.

    If you want to use your code, alter

    <?php if (has_post_video()) the_post_video(640,360) ?>
    <?php if (has_post_thumbnail( $post->ID )) {


    <?php if (has_post_video()) the_post_video(640,360) ?>
    <?php elseif (has_post_thumbnail( $post->ID )) {


Viewing 1 replies (of 1 total)
  • The topic ‘Problem with featured video/image’ is closed to new replies.