twentyfourteen_post_thumbnail
Display an optional post thumbnail.
Description
twentyfourteen_post_thumbnail();
Wraps the post thumbnail in an anchor element on index views, or a div element when on single views.
Usage
if ( !function_exists( 'twentyfourteen_post_thumbnail' ) ) { require_once '/inc/template-tags.php'; } // NOTICE! Understand what this does before running. $result = twentyfourteen_post_thumbnail();
Defined (1)
The function is defined in the following location(s).
- /inc/template-tags.php
- function twentyfourteen_post_thumbnail() {
- if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
- return;
- }
- if ( is_singular() ) :
- ?>
- <div class="post-thumbnail">
- <?php
- if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) {
- the_post_thumbnail( 'twentyfourteen-full-width' );
- } else {
- the_post_thumbnail();
- }
- ?>
- </div>
- <?php else : ?>
- <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true">
- <?php
- if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) {
- the_post_thumbnail( 'twentyfourteen-full-width' );
- } else {
- the_post_thumbnail( 'post-thumbnail', array( 'alt' => get_the_title() ) );
- }
- ?>
- </a>
- <?php endif; // End is_singular()
- }