Instantly share code, notes, and snippets.

@IkeTen /avatar-header.php Secret
Last active Nov 3, 2016

Embed
What would you like to do?
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