Status
Für weitere Antworten geschlossen.
T

tomi99

Guest
Hallo zusammen,
ich optimiere gerade meine Webseite und würde gerne die Avatar vor den Autoren unten in der Beitrag in Thema einbauen ohne ein Plugin.

Hat jemand eine Idee?
Vielen Dank

 

iosguru

Member
Mitglied seit
2 April 2019
Beiträge
5
du kannst folgenden Code in der functions.php einfüge

*Function to Add Author Box*/function add_author_box($content){if( is_single() ) {/*Editable*/$img_ext = 'jpg'; //Replace this with png if you are using PNG images.$img_size = 82; //Edit this value to change the author image size./*Getting author info*/$auth_id = get_the_author_meta('ID'); //Get author ID.$auth_name = get_the_author_meta('display_name'); // Get author name.$auth_des = get_the_author_meta('description'); // Get author description.$auth_page_url = get_author_posts_url($auth_id); //Get author Page URL.$upload_dir = wp_upload_dir();$uploads_folder_url = $upload_dir['url']; //uploads folder URL.$uploads_folder_path = $upload_dir['path']; //uploads folder path.$auth_avt = $uploads_folder_url.'/author'.$auth_id.'.'.$img_ext; //author image URL.$auth_avt_path = $uploads_folder_path.'/author'.$auth_id.'.'.$img_ext; //author image path./*Check if user uploaded avatar exists*/if(file_exists($auth_avt_path)){$auth_img = '<img src="'. $auth_avt .'" width="'. $img_size .'" height="'. $img_size .'" >'; //If user uploaded avatar exists, use it in the display.}else{$auth_img = get_avatar( $auth_id, $img_size ); //If user uploaded avatar does not exist use gavatar.}/*Output*/$content .= "<div id='authorbox'><h3>Article by <a href='$auth_page_url'>$auth_name</a></h3> $auth_img $auth_des </div>";}return $content;}add_filter ( 'the_content', 'add_author_box', 0 );

Danke, funktioniert super!

 
Status
Für weitere Antworten geschlossen.
Oben