I need to display an avatar in the post info position which i have written the code for but i only want to display it on the most recent post on the home page and not a specific post as this will change when a new post id published.
Couldn’t find a conditional tag which handles this.
I’m using the code in a custom function with genesis_hook in the child theme.
function latest_post_author_avatars() {
if (is_single() || is_home() ) {
echo get_avatar(get_the_author_id(), 40);
}
}
add_action('genesis_after_post_title', 'latest_post_author_avatars');
// Here’s the final solution which works. Thanks to both of you.
function latest_post_author_avatars() {
global $wp_query;
if (is_single() || is_home() && 0 === $wp_query->current_post) {
echo get_avatar(get_the_author_id(), 40);
}
}
add_action('genesis_after_post_title', 'latest_post_author_avatars');