twentyfifteen_post_thumbnail

Display an optional post thumbnail.

Description

twentyfifteen_post_thumbnail(); 

Wraps the post thumbnail in an anchor element on index views, or a div element when on single views.


Usage

  1. if ( !function_exists( 'twentyfifteen_post_thumbnail' ) ) { 
  2. require_once '/inc/template-tags.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = twentyfifteen_post_thumbnail(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/inc/template-tags.php  
  1. function twentyfifteen_post_thumbnail() { 
  2. if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) { 
  3. return; 
  4.  
  5. if ( is_singular() ) : 
  6. ?> 
  7.  
  8. <div class="post-thumbnail"> 
  9. <?php the_post_thumbnail(); ?> 
  10. </div><!-- .post-thumbnail --> 
  11.  
  12. <?php else : ?> 
  13.  
  14. <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true"> 
  15. <?php 
  16. the_post_thumbnail( 'post-thumbnail', array( 'alt' => get_the_title() ) ); 
  17. ?> 
  18. </a> 
  19.  
  20. <?php endif; // End is_singular()