Get author ID of a post in wordpress

前端 未结 5 2101
悲哀的现实
悲哀的现实 2021-02-18 15:49

Im creating a loop where it pulls info about a users activity. the code is on the author page and what i want to to is get the current author ID, so based on what author page th

5条回答
  •  渐次进展
    2021-02-18 16:17

    Try this

    global $wp_query;
    $thePostID = $wp_query->post->ID;
    $postdata = get_postdata($thePostID);
    $authorID = $postdata['Author ID'];
    

    or something like this

    post_author; ?>
    <?php echo the_author_meta( 'display_name' , $author_id ); ?>
     
    

提交回复
热议问题