简体   繁体   中英

How do you link to the profile page of the author of a post?

I'm assisting a client with a custom Wordpress theme where the previous developer linked to the blog author's profile within each current post. Presently, it is not linking to the author's profile and I'm attempting to fix the issue.

Below is the code that I've attempted to link to the author's profile of the current post, but it has not working.

   <?php $username = get_userdata( $post->post_author ); ?>
   <?php print '<div class="header-author-share"><span class="author vcard"> <a href="<?php echo get_author_posts_url( $post->post_author); ?>">'.$avatar.'<span class="author-information">' . esc_html(get_the_author() ) . '</span></a><span class="date-time-reading"> . 
   <span class="post-date-spn">'.get_the_date('M 
   jS',get_the_ID()).'</span><span class="post-date- 
   time">'.do_shortcode('[rt_reading_time postfix="min" 
   postfix_singular="min"]').' read</span></span></span></div>';?>

I expecting the "author-information" to be linked to the current author's profile page. Am I missing something here?

EDIT:

As pointed out in a comment below your question, you have a syntax string error. Try fixing this first.


You can try fetching the info using this wordpress function:

$authorDescr = get_the_author_meta( 'user_description', $post->post_author );

Then simply add $authorDescr to the content of the element.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM