This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Author Picture

#26562
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

I assume those are post type results, and you want to display their author image. Well, there is no option for that on the back-end, but it might be possible via a custom code.

Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

add_filter( 'asp_results', 'asp_get_author_image_on_cpt', 10, 1 );
function asp_get_author_image_on_cpt($results) {
	foreach ( $results as $k => &$r ) {
		if ( $r->content_type == 'pagepost' ) {
			if ( empty($r->image) ) {
				$post_author_id = get_post_field( 'post_author', $r->id );
				$img = get_avatar_url($post_author_id);
				if ( !empty($img) ) {
					$r->image = $img;
				}
			}
		}
	}
    return $results;
}