Site logo

Archived topic

Post author name not visible when author has no posts

2 replies · Started by George on July 2, 2022

Viewing posts 1–3 of 3

I've created an author bio header block element where I display post author avatar and post author name along with another author description element. Both are being displayed in the Author Archives.

When viewing an author that has no posts, the author description is visible but the author's name and avatar are not (avatar might seem that it's there but it's actually not visible since when a user with no posts and an avatar available is viewed in the front end, the avatar still displays blank).

I've included a video with my setup so you can see the issue.

Ok, I think I resolved it myself, lol. I suspect the behavior happens because of the default functionality to not show authors with no posts since GP reads authors from default archives? In any case, I decided to use a shortcode for displaying the author name:

//Author name shortcode
function author_name_shortcode(){
    global $post;
    $post_id = $post->ID;
    $author = get_the_author($post_id);
    return $author;
}
add_shortcode('post_author','author_name_shortcode');

Works as expected, unless you have another more streamlined solution.

Glad to hear you found a solution

This archived topic is closed to new replies.