forked from mirror/_s
_s: Add featured images to Post and Pages with the ability to hide them via Content Options.
_s: Fix Travis CI error _s: Add missing coma in array
This commit is contained in:
parent
f9d4a471e5
commit
387df73308
|
@ -35,6 +35,11 @@ function _s_jetpack_setup() {
|
||||||
'author' => '.byline',
|
'author' => '.byline',
|
||||||
'comment' => '.comments-link',
|
'comment' => '.comments-link',
|
||||||
),
|
),
|
||||||
|
'featured-images' => array(
|
||||||
|
'archive' => true,
|
||||||
|
'post' => true,
|
||||||
|
'page' => true,
|
||||||
|
),
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
add_action( 'after_setup_theme', '_s_jetpack_setup' );
|
add_action( 'after_setup_theme', '_s_jetpack_setup' );
|
||||||
|
|
|
@ -100,3 +100,36 @@ if ( ! function_exists( '_s_entry_footer' ) ) :
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
if ( ! function_exists( '_s_post_thumbnail' ) ) :
|
||||||
|
/**
|
||||||
|
* Displays an optional post thumbnail.
|
||||||
|
*
|
||||||
|
* Wraps the post thumbnail in an anchor element on index views, or a div
|
||||||
|
* element when on single views.
|
||||||
|
*/
|
||||||
|
function _s_post_thumbnail() {
|
||||||
|
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_singular() ) :
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="post-thumbnail">
|
||||||
|
<?php the_post_thumbnail(); ?>
|
||||||
|
</div><!-- .post-thumbnail -->
|
||||||
|
|
||||||
|
<?php else : ?>
|
||||||
|
|
||||||
|
<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true">
|
||||||
|
<?php
|
||||||
|
the_post_thumbnail( 'post-thumbnail', array(
|
||||||
|
'alt' => the_title_attribute( 'echo=0' ),
|
||||||
|
) );
|
||||||
|
?>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<?php endif; // End is_singular().
|
||||||
|
}
|
||||||
|
endif;
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
|
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
|
||||||
</header><!-- .entry-header -->
|
</header><!-- .entry-header -->
|
||||||
|
|
||||||
|
<?php _s_post_thumbnail(); ?>
|
||||||
|
|
||||||
<div class="entry-content">
|
<div class="entry-content">
|
||||||
<?php
|
<?php
|
||||||
the_content();
|
the_content();
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</header><!-- .entry-header -->
|
</header><!-- .entry-header -->
|
||||||
|
|
||||||
|
<?php _s_post_thumbnail(); ?>
|
||||||
|
|
||||||
<div class="entry-summary">
|
<div class="entry-summary">
|
||||||
<?php the_excerpt(); ?>
|
<?php the_excerpt(); ?>
|
||||||
</div><!-- .entry-summary -->
|
</div><!-- .entry-summary -->
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
endif; ?>
|
endif; ?>
|
||||||
</header><!-- .entry-header -->
|
</header><!-- .entry-header -->
|
||||||
|
|
||||||
|
<?php _s_post_thumbnail(); ?>
|
||||||
|
|
||||||
<div class="entry-content">
|
<div class="entry-content">
|
||||||
<?php
|
<?php
|
||||||
the_content( sprintf(
|
the_content( sprintf(
|
||||||
|
|
Reference in New Issue