-
-
Save IkeTen/df47a410e3ece57fd75b1793af0cd643 to your computer and use it in GitHub Desktop.
Overlay Post title on featured image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The Template for displaying author gravatar and author link. | |
* Place this template in your GeneratePress child theme | |
* @package GeneratePress | |
*/ | |
// No direct access, please | |
if ( ! defined( 'ABSPATH' ) ) exit; | |
?> | |
<div class="header-avatar"> | |
<?php | |
the_post(); // queue first post | |
echo get_avatar( get_the_author_meta( 'email' ), 200 ); // echo author gravatar | |
rewind_posts(); // rewind the loop | |
?> | |
<p> | |
<?php | |
the_post(); // queue first post | |
echo get_the_author_link(); // echo author url | |
rewind_posts(); // rewind the loop | |
?> | |
</p> | |
</div> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The Template for displaying single post title over featured background image. | |
* * Place this template in your GeneratePress child theme | |
* @package GeneratePress | |
*/ | |
// No direct access, please | |
if ( ! defined( 'ABSPATH' ) ) exit; | |
?> | |
<?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?> | |
<div id="entry-header-wrap" class="entry-header-wrap"> | |
<div class="entry-header-bg" style="background-image: url('<?php echo $backgroundImg[0]; ?>');"></div> | |
<p class="entry-meta"> | |
<span class="date updated time"> | |
<time class="entry-modified-time" itemprop="dateModified" datetime="<?php echo get_the_modified_time('Y-m-d', $post->ID); ?>"><?php echo get_the_modified_time('Y-m-d', $post->ID); ?></time> | |
</span> / | |
<span class="entry-categories"> | |
<?php the_category(', '); ?> | |
</span> | |
</p> | |
<header class="entry-header"> | |
<h2 class="entry-title" itemprop="headline"><?php the_title(); rewind_posts();?></h2> | |
</header> | |
</div> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
*CSS for Featured background image with post title overlay | |
*Edit to suit your site color scheme | |
*/ | |
/*Spacing in Main Header Div*/ | |
#entry-header-wrap.entry-header-wrap { | |
background-color: #20232c; | |
margin-bottom: 10px; | |
padding: 5% 10% 7% 10%; | |
position: relative; | |
text-align: center; | |
} | |
/*Post Header Featured Background Image Properties*/ | |
#entry-header-wrap .entry-header-bg { | |
background-repeat: no-repeat; | |
background-position: center center; | |
display: block; | |
background-size: cover; | |
width: 100%; | |
height: 100%; | |
opacity: .6; | |
position: absolute; | |
top: 0; | |
left: 0; | |
z-index: 0; | |
overflow: hidden; | |
} | |
/*Post Header Featured Meta Properties*/ | |
#entry-header-wrap p.entry-meta { | |
color: #adaeb3; | |
font-family: "museo-sans-rounded",sans-serif; | |
font-size: 13.5px; | |
font-weight:700; | |
color:#fff; | |
font-style: normal; | |
letter-spacing: .65px; | |
margin-bottom: 20px; | |
text-transform: uppercase; | |
} | |
#entry-header-wrap .entry-meta a:hover { | |
color: #fff | |
} | |
#entry-header-wrap .entry-categories a { | |
border: none; | |
color: #fabd29; | |
font-style: normal; | |
} | |
#entry-header-wrap .entry-header, #entry-header-wrap .entry-meta { | |
position: relative; | |
z-index: 99; | |
} | |
/*Post Header Featured Title Properties*/ | |
div#entry-header-wrap.entry-header-wrap .entry-header { | |
margin-top: 0%; | |
margin-bottom: 5%; | |
top:-10px; | |
} | |
.single-post header.entry-header { | |
margin-top: 10%; | |
} /*Fall back for main post header title in content area*/ | |
.page-header-image-single.grid-container.grid-parent { | |
margin-top: 10%; | |
} /*Fall back for main post featured image in content area*/ | |
#entry-header-wrap .entry-header .entry-title { | |
color: #fff; | |
line-height: 1.15; | |
margin: 50px 0 0; | |
padding: 0; | |
font-size: 61px; | |
font-weight: 700; | |
} | |
/*Post Header Author Avatar Properties*/ | |
.single .header-avatar { | |
margin-bottom: -110px; | |
position: relative; | |
top: -40px; | |
text-align: center; | |
z-index: 9999; | |
} | |
.single .header-avatar img { | |
border: 7px solid #f5f5f6; | |
border-radius: 50%; | |
float: none; | |
height: 66px; | |
width: 66px; | |
} | |
.single .header-avatar p { | |
font-size: 14px; | |
letter-spacing: 1px; | |
margin-bottom: 0; | |
text-transform: uppercase; | |
font-family: "museo-sans-rounded",sans-serif; | |
font-weight:700; | |
} | |
/*Post Header Featured Author Avatar Url Properties*/ | |
.single .header-avatar p a { | |
color: #adaeb3; | |
} | |
.single .header-avatar p a:hover { | |
color: #fabd29; | |
} | |
/*Mobile Responsive CSS */ | |
/*Mobile Responsive CSS Max width 400px*/ | |
@media only screen and (max-width: 400px) { | |
#entry-header-wrap .entry-header .entry-title{ | |
line-height: 1.15; | |
padding: 0; | |
font-size: 27px; | |
line-height: 1.11; | |
margin:25px 0; | |
} | |
div#entry-header-wrap { | |
} | |
#entry-header-wrap.entry-header-wrap{ | |
margin-bottom: 10px; | |
padding: 5% 5% 12.5% 5%; | |
} | |
div#entry-header-wrap.entry-header-wrap .entry-header { | |
top: 0px; | |
} | |
#entry-header-wrap p.entry-meta { | |
font-size: 12px; | |
} | |
} | |
/*Mobile Responsive CSS Min width 400px and max 960*/ | |
@media only screen and (min-width: 401px) and (max-width: 960px){ | |
#entry-header-wrap .entry-header .entry-title{ | |
line-height: 1.15; | |
padding: 0; | |
font-size: 27px; | |
line-height: 1.11; | |
margin:25px 0; | |
} | |
#entry-header-wrap.entry-header-wrap{ | |
margin-bottom: 10px; | |
padding: 5% 5% 12.5% 5%; | |
} | |
div#entry-header-wrap.entry-header-wrap .entry-header { | |
top: 0px; | |
} | |
} | |
/*Mobile Responsive CSS Min width 641px and max 960*/ | |
@media only screen and (min-width:641px) and (max-width: 960px){ | |
#entry-header-wrap .entry-header .entry-title { | |
font-size: 40px; | |
margin: 25px 0; | |
} | |
} | |
/*Post Header Featured Meta and Title Text Decoration*/ | |
/*Post Header Featured Meta and Title Background Color*/ | |
#entry-header-wrap .entry-header .entry-title, #entry-header-wrap time.entry-modified-time, #entry-header-wrap span.entry-categories{ | |
background-color: rgba(83, 75, 75, 0.3) | |
} | |
/*Post Header Featured Meta and Title Decoration*/ | |
#entry-header-wrap span.entry-categories,#entry-header-wrap time.entry-modified-time ,#entry-header-wrap .entry-header .entry-title{ | |
border-radius: 2px; | |
padding: 1px 6px; | |
} | |
/*Post Header Featured Category tag Decoration*/ | |
#entry-header-wrap span.entry-categories { | |
border: 1px solid #ff9525; | |
} | |
#entry-header-wrap span.entry-categories:hover { | |
background: #ff9525; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Generate child theme functions and definitions | |
* Add this code to your Child theme functions.php | |
* @package Generate | |
*/ | |
// Calls featured-header.php for post header custom featured image overlay title on single posts | |
add_action('generate_after_header','featured_header_include'); | |
function featured_header_include() { | |
// Call funtion on single post type only | |
if ( is_singular( 'post' ) ) { | |
get_template_part( 'featured', 'header' ); | |
} | |
} | |
// Calls avatar-header.php for author avatar/ url on single posts | |
add_action( 'generate_inside_container','author_avatar_include'); | |
function author_avatar_include() { | |
// Call funtion on single post type only | |
if ( is_singular( 'post' ) ) { | |
get_template_part( 'avatar', 'header' ); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment