Hide the author box for a specific ‘Author’ user

function custom_show_linked_author_meta_before_content($content) {
global $post;

// Get the post author’s ID
$author_id = $post->post_author;

// Get the user object for the post author
$author_user = get_userdata($author_id);

// Check if the post author has the ‘author’ role
if ($author_user && in_array(‘author’, $author_user->roles)) {
// Get the author name and author archive URL
$author_name = get_the_author_meta(‘display_name’, $author_id);
$author_archive_url = get_author_posts_url($author_id);

// Display the linked author meta before the content
$linked_author_meta = ‘<div class=”post-author-meta”>’;
$linked_author_meta .= ‘<a href=”‘ . esc_url($author_archive_url) . ‘”>’ . esc_html($author_name) . ‘</a>’;
$linked_author_meta .= ‘</div>’;

$content = $linked_author_meta . $content;
}

return $content;
}

// Hook into the ‘the_content’ filter to modify the content
add_filter(‘the_content’, ‘custom_show_linked_author_meta_before_content’);

Scroll to Top