0

I am trying to create a user profile template using author.php. However, the template remains blank if I try to see the profile of a user that has not created any posts.

www.website.com/author/user1 -> Has written Posts -> Template shows User info

www.website.com/author/user2 -> Subscriber account -> template remains empty

How can I tell Wordpress to fill in the information for every user?

Edit: My Code so far:

<?php
get_header();
$userID = get_the_author_meta('ID');
$user = get_userdata($userID);
?>


<div class="profile-wrapper">

    <div class="row justify-content-center user-info">
        <div class="col-lg-5 text-center">
            <span><?php echo get_avatar($user->ID, 150) ?></span>
            <h2 class="heading-semibig"><?php echo $user->display_name ?></h2>
        </div>
    </div>

</div>
2
  • What is the code in the template? Are you trying to output the user information after if ( have_posts() ) :? Commented Jun 28, 2018 at 14:06
  • Please see my edit. I don't have any if statements
    – Philipp K
    Commented Jun 28, 2018 at 14:19

1 Answer 1

2

get_the_author_meta( 'ID' ) gets the ID of the author of the current post. If there's no post there's no author.

Use get_queried_object_id() instead. When used on author archives (i.e. author.php) it will be the ID of the author, regardless of whether or not they have posts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.