How To Get URL To Post Author's User BuddyPress Avatar Inside Wordpress Post Loop

后端 未结 2 527
花落未央
花落未央 2021-01-14 18:01

The Question

How to get just the URL to a post author\'s avatar?

The Requirements

I want the url to the image that

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-14 18:25

    I'm not sure this answer was incorporated into Cale's answer so I've undeleted it in case it's of use to anyone else.

    in the loop (in say single.php)

    
    

    or call from functions.php file in theme folder

    the call (from your loop in say single.php)

    
    

    the function (place in functions.php)

    function custom_get_author_avatar_url() {
        $authorUserID = get_the_author_meta('ID');  // get the user id of the post author
        echo bp_core_fetch_avatar ( 
        array(  'item_id'   => $authorUserID,       // output user id of post author
                'type'      => 'full',
                'html'      => FALSE            // FALSE = return url, TRUE (default) = return url wrapped with html and css classes
        ) 
        ); 
    }
    

提交回复
热议问题