Skip to content

Instantly share code, notes, and snippets.

@IkeTen
Last active November 3, 2016 23:36
Show Gist options
  • Save IkeTen/df47a410e3ece57fd75b1793af0cd643 to your computer and use it in GitHub Desktop.
Save IkeTen/df47a410e3ece57fd75b1793af0cd643 to your computer and use it in GitHub Desktop.
Overlay Post title on featured image
<?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>
<?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