Skip to content

Commit

Permalink
added option to display Featured Image captions on the post pages
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSibley committed Aug 4, 2020
1 parent 05bfa34 commit c37f912
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 5 deletions.
6 changes: 6 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ function ct_apex_featured_image() {

if ( is_singular() ) {
$featured_image = '<div class="featured-image">' . get_the_post_thumbnail( $post->ID, 'full' ) . '</div>';
if ( get_theme_mod('featured_image_captions') == 'yes' ) {
$caption = get_post( get_post_thumbnail_id() )->post_excerpt;
if ( !empty($caption) ){
$featured_image .= '<div class="caption">' . wp_kses_post($caption) . '</div>';
}
}
} else {
$featured_image = '<div class="featured-image"><a href="' . esc_url( get_permalink() ) . '">' . esc_html( get_the_title() ) . get_the_post_thumbnail( $post->ID, 'full' ) . '</a></div>';
}
Expand Down
16 changes: 16 additions & 0 deletions inc/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,22 @@ function ct_apex_add_customizer_content( $wp_customize ) {
'no' => __( 'No', 'apex' )
)
) );
// setting - featured image captions
$wp_customize->add_setting( 'featured_image_captions', array(
'default' => 'no',
'sanitize_callback' => 'ct_apex_sanitize_yes_no_settings'
) );
// control - featured image captions
$wp_customize->add_control( 'featured_image_captions', array(
'label' => __( 'Show the Featured Image caption on the post page?', 'apex' ),
'section' => 'apex_additional',
'settings' => 'featured_image_captions',
'type' => 'radio',
'choices' => array(
'yes' => __( 'Yes', 'apex' ),
'no' => __( 'No', 'apex' )
)
) );

/***** Custom CSS *****/

Expand Down
13 changes: 12 additions & 1 deletion rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ h1 {
/* 24px */
}

.woocommerce-account .woocommerce-MyAccount-navigation li a, .singular-attachment .attachment-caption, .widget > *, .further-reading span, .post-tags a, .post-byline, .sticky-status, .comments-link, .more-link, .tagline, .site-footer .design-credit span, .comment-footer a,
.woocommerce-account .woocommerce-MyAccount-navigation li a, .singular-attachment .attachment-caption, .widget > *, .further-reading span, .post-tags a, .post-byline, .featured-image + .caption, .sticky-status, .comments-link, .more-link, .tagline, .site-footer .design-credit span, .comment-footer a,
.comment-footer span, #cancel-comment-reply-link, .comment-respond label, input[type=submit], input[type=text],
input[type=email],
input[type=password],
Expand Down Expand Up @@ -1215,6 +1215,10 @@ li.pingback {
padding: 4px 12px 4px 4px;
font-size: 13px;
}
.featured-image + .caption {
margin-top: 6px;
text-align: center;
}

.post-container {
padding: 0 6.25%;
Expand Down Expand Up @@ -1354,6 +1358,13 @@ li.pingback {
.error404 .featured-video {
margin-bottom: 2.25em;
}
.singular .featured-image + .caption,
.singular .featured-video + .caption,
.error404 .featured-image + .caption,
.error404 .featured-video + .caption {
margin-top: -32px;
margin-bottom: 14px;
}
}
.search-form input[type=submit] {
min-width: 100px;
Expand Down
2 changes: 1 addition & 1 deletion rtl.min.css

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions sass/_post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
padding: 4px 4px 4px 12px;
font-size: 13px;
}
+ .caption {
@extend %twelve-pixels;
// margin: -$baseline-height 0 $baseline-height;
margin-top: 6px;
text-align: center;
}
}
.post-container {
padding: 0 $column * 2;
Expand Down Expand Up @@ -211,6 +217,11 @@
.featured-image,
.featured-video {
margin-bottom: $baseline-height * 1.5;

+ .caption {
margin-top: -32px;
margin-bottom: 14px;
}
}
}
}
13 changes: 12 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ h1 {
/* 24px */
}

.woocommerce-account .woocommerce-MyAccount-navigation li a, .singular-attachment .attachment-caption, .widget > *, .further-reading span, .post-tags a, .post-byline, .sticky-status, .comments-link, .more-link, .tagline, .site-footer .design-credit span, .comment-footer a,
.woocommerce-account .woocommerce-MyAccount-navigation li a, .singular-attachment .attachment-caption, .widget > *, .further-reading span, .post-tags a, .post-byline, .featured-image + .caption, .sticky-status, .comments-link, .more-link, .tagline, .site-footer .design-credit span, .comment-footer a,
.comment-footer span, #cancel-comment-reply-link, .comment-respond label, input[type=submit], input[type=text],
input[type=email],
input[type=password],
Expand Down Expand Up @@ -1215,6 +1215,10 @@ li.pingback {
padding: 4px 4px 4px 12px;
font-size: 13px;
}
.featured-image + .caption {
margin-top: 6px;
text-align: center;
}

.post-container {
padding: 0 6.25%;
Expand Down Expand Up @@ -1354,6 +1358,13 @@ li.pingback {
.error404 .featured-video {
margin-bottom: 2.25em;
}
.singular .featured-image + .caption,
.singular .featured-video + .caption,
.error404 .featured-image + .caption,
.error404 .featured-video + .caption {
margin-top: -32px;
margin-bottom: 14px;
}
}
.search-form input[type=submit] {
min-width: 100px;
Expand Down
2 changes: 1 addition & 1 deletion style.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion style.min.css

Large diffs are not rendered by default.

0 comments on commit c37f912

Please sign in to comment.