Show activity on this post. $post_id = get_the_ID(); $author_id = get_post_field ('post_author', $post_id); $display_name = get_the_author_meta( 'nickname' , $author_id ); echo $display_name; Note: You need to use this function inside the loop.
In WordPress, we can use the get_the_author_meta(string $field) function to retrieve the author's details stored in the database object. get_the_author_meta() function return the author's requested information in string format if available, otherwise, it returns an empty string.
You can get by get_the_author_meta() wordpress function to get author email address. <? php $user_email = get_the_author_meta('user_email'); ?> Get the email address for user ID 25, and echo it using their display name as the anchor text.
I figured it out.
<?php $author_id=$post->post_author; ?>
<img src="<?php the_author_meta( 'avatar' , $author_id ); ?> " width="140" height="140" class="avatar" alt="<?php echo the_author_meta( 'display_name' , $author_id ); ?>" />
<?php the_author_meta( 'user_nicename' , $author_id ); ?>
If you want it outside of loop then use the below code.
<?php
$author_id = get_post_field ('post_author', $cause_id);
$display_name = get_the_author_meta( 'display_name' , $author_id );
echo $display_name;
?>
<?php
$field = 'display_name';
the_author_meta($field);
?>
Valid values for the $field
parameter include:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With