WordPress.org

Ready to get started?Download WordPress

Forums

Video Thumbnails
[resolved] Conditional thumbnail on index.php and single.php (5 posts)

  1. Joseph
    Member
    Posted 2 years ago #

    Currently using this plugin, and it works great.

    Would it be possible to display a thumbnail on the index.php page, but not on the single.php page, depending on if it's a thumbnail from the video?

    http://wordpress.org/extend/plugins/video-thumbnails/

  2. Sutherland Boswell
    Member
    Plugin Author

    Posted 2 years ago #

    Yep, just use

    <?php if( ( $video_thumbnail = get_video_thumbnail() ) != null && !is_single() ) { echo "<img src='" . $video_thumbnail . "' />"; } ?>

  3. Joseph
    Member
    Posted 2 years ago #

    Hmm. Didn't seem to do what I want. The video thumbnail still displays fine on my homepage, but still displays on the single post page. If it's a thumbnail specifically from the video, then I don't want it to show up at all on the single post.

    This is what I have in my single.php file:

    <div id="single-thumb">
    
    <?php if( ( $video_thumbnail = get_video_thumbnail() ) != null && !is_single() ) {
    	echo "<img src='" . $video_thumbnail . "' />"; } ?>
    
    	<?php if ( has_post_thumbnail() ) {
    				the_post_thumbnail('post-thumb'); ?>
    			<?php } ?>
    </div>
  4. Sutherland Boswell
    Member
    Plugin Author

    Posted 2 years ago #

    So the plugin settings have the video thumbnail set as a featured image? If that's the case you can try this in single.php:

    <?php if( get_video_thumbnail() == null &&  has_post_thumbnail() ) { ?>
    <div id="single-thumb">
    	<?php the_post_thumbnail('post-thumb'); ?>
    </div>
    <?php } ?>
  5. Joseph
    Member
    Posted 2 years ago #

    That did the trick. Thanks for your help!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic