Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Author page is empty, including the hero Element. Why?

  • Hello,

    I have several users on my website and have created a hero Element to display each user’s name, avatar, and description, on each author archive.

    Now I have some users with no blog posts, but who nonetheless have an avatar, name, and description. However, when I go to their author archive page, nothing gets displayed — not even their names/avatar/descriptions. The structural elements of the hero Element are present (e.g. containers, etc.), but it’s all empty so I basically get a white page.

    Is that normal behavior? I would like the user information to display even if they have not authored any blog post.

  • Hi John,

    That’s normal behavior. Archive pages with no posts default to the no-results.php template.

    It’s a bit complicated to alter this behavior. You’ll need to use the Child theme, create a template for author archives specifically, and alter this part of the code: https://github.com/tomusborne/generatepress/blob/adfe090929b0515cdf894f4c6b722cfe8c0790dc/archive.php#:~:text=generate_do_template_part(%20%27none%27%20)%3B

    Then, create a template for your archive page that don’t have posts.

    Alternatively, I would suggest adding a post for all users.

  • I understand; thank you Fernando.

    I want to avoid modifying the theme, even from a Child Theme, to avoid having to maintain it ongoing with future updates.

    Instead, I’ve chosen to redirect the empty author archives to a static page where I can give some explanation to the user. I used this code snippet:

    add_action( 'template_redirect', 'redirect_empty_author_archive' );
    function redirect_empty_author_archive() {
        if ( is_author() && !have_posts() ) {
            wp_redirect( home_url( '/no-user-info' ), 301 );
            exit;
        }
    }

    Sharing here for anyone who might be interested in a similar solution.

    Thank you

  • I see. You’re welcome, John! Thank you for sharing your solution!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.