I can't seem to find the function code that will work for this to actually completely remove the author from posts only if the author is an admin. I have generic posts which will be published by admin but I do not want to have the admins name appear as an author (need it to be completely removed) Is there a way to do this without hiding it but rather completely remove it?
Worse case I can hide the Div element but haven't been able to find the code to accomplish this when the author of the post is an admin only. I can also use the user ID if that works as well to remove the author. Thanks!
function get_user_role($post_authr_id) {
$user = new WP_User($post_authr_id);
return array_shift($user->roles);
}
global $post;
$post_authr_id = $post->post_author;
$auhtor_role = get_user_role($post_authr_id);
if($auhtor_role !== 'administrator'){
//if auhor role is not admin display auhtor name
/*
your author display code here
*/
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.