Get author ID of a post in wordpress

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

    On an author archive the following will get the author ID:

    $author_ID = get_query_var('author');
    

    This will get you a lot more information:

    $pageobj = get_queried_object();
    

    Reference:

    http://codex.wordpress.org/Function_Reference/get_query_var
    http://codex.wordpress.org/Function_Reference/get_queried_object

提交回复
热议问题