#32956
 sharmstr
Moderator

I’m displaying the authors avatar within the post meta. To do it, I’m doing this.

COPY CODE

/**
* Override Post Author Meta to include avatar
**/
if ( ! function_exists( 'kleo_entry_meta' ) ) :
	/**
	 * Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
	 * Create your own kleo_entry_meta() to override in a child theme.
	 * @since 1.0
	 */
	 
	function kleo_entry_meta($echo=true, $att=array()) {
	
		$meta_list = array();
		
		// Translators: used between list items, there is a space after the comma.
		$categories_list = get_the_category_list( __( ', ', 'kleo_framework' ) );

		// Translators: used between list items, there is a space after the comma.
		$tag_list = get_the_tag_list( '', __( ', ', 'kleo_framework' ) );

		$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
			esc_url( get_permalink() ),
			esc_attr( get_the_time() ),
			esc_attr( get_the_date( 'c' ) ),
			esc_html( get_the_date() )
		);

		$author = sprintf( '<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
			esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
			esc_attr( sprintf( __( 'View all posts by %s', 'kleo_framework' ), get_the_author() ) ),
			get_the_author()
		);
		
		if (is_single()):
			$avatar = get_avatar( get_the_author_meta( 'ID' ), 100 );
			$meta_list[] = '<small class="post-author-avatar">'.$avatar.'</small>';
		endif;
		$meta_list[] = '<small class="meta-author">'.$author.'</small>';
		$meta_list[] = '<small>'.$date.'</small>';
		
		$cat_tag = array();
		
		if ( $categories_list ) {
			$cat_tag[] = $categories_list;
		}
		
		if ($tag_list) {
			$cat_tag[] = $tag_list;
		}
		if (!empty($cat_tag)) {
			$meta_list[] = '<small class="meta-category">'.implode(", ",$cat_tag).'</small>';
		}
		
		//comments
		if (!isset($att['comments']) || (isset($att['comments']) && $att['comments'] !== false)) {
		$meta_list[] = '<small class="meta-comment-count"><a href="'. get_permalink().'#comments">'.get_comments_number().' <i class="icon-chat-1 hover-tip" 
			data-original-title="'.sprintf( _n( 'This article has one comment', 'This article has %1$s comments', get_comments_number(), 'kleo_framework' ),number_format_i18n( get_comments_number() ) ).'" 
			data-toggle="tooltip" 
			data-placement="top"></i></a></small>';
		}
		
		if ($echo) {
			echo implode(", ", $meta_list);
		}
		else {
			return implode(", ", $meta_list);
		}
		
	}
endif;

Now, I’m only displaying in on the post page (single), not the listing pages. I haven’t tested it, but you can try removing the if single around this bit of code

COPY CODE

if (is_single()):
	$avatar = get_avatar( get_the_author_meta( 'ID' ), 100 );
	$meta_list[] = '<small class="post-author-avatar">'.$avatar.'</small>';
endif;

To style the avatar, I use this (you’ll probably want it smaller for listing pages)

COPY CODE


/* Format Post Author Avatar */

.post-author-avatar {
	display: block;
}
.post-author-avatar img {
	width: 60px;
	height: 60px;
	overflow: hidden;
	border-radius: 100%;
	border-style: solid;
	border-width: 5px;
	border-color: #f7f7f7;
}

I’ve attached a screenshot so you can see what it supposed to look like.

Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

Attachments:

Log in with your credentials

Forgot your details?