Get author ID of a post in wordpress

前端 未结 5 2085
悲哀的现实
悲哀的现实 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:07

    Try with this :

    post_author; ?>
    

    it will give you current author id.

    or this one will helps you more:

    global $current_user;
    get_currentuserinfo();                      
    
    $args = array(
        'author'        =>  $current_user->ID, // I could also use $user_ID, right?        
        );
    
    // get his posts 'ASC'
    $current_user_posts = get_posts( $args );
    

    Thanks.

提交回复
热议问题