• Is there a way to assign the author’s description to a variable in order to output an “About the Author” section if it is not empty?

    I’ve got this far:

    <?php $userdata = get_userdata(1); ?>
    <?php if ($userdata->description != '') { ?>
    <h2>About the Author</h2>
    <p><?php _e($userdata->description); ?></p>
    <?php } ?>

    But can’t find a way to get the author_id within the loop in order to pass it to the get_userdata function.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter robertlove

    (@robertlove)

    In the loop:

    <?php $author_id = get_the_author_ID(); ?>

    Then, wherever you want to output:

    <?php $userdata = get_userdata($author_id); ?>
    <?php if ($userdata->description != '') { ?>
    <h2>About the Author</h2>
    <p><?php _e($userdata->description); ?></p>
    <?php } ?>

    Thanks for the heads up on get_the_author_ID() Ei Sabai. Who needs the experts when I have you sitting in the next office ??

    Just wanted to say thanks for posting the solution – it helped me solve a problem I was having with userdata->description.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to assign the_author_description to variable’ is closed to new replies.