The is_multi_author() WordPress PHP function determines if a site has more than one author who has published posts.
Usage
is_multi_author()
Example:
Input:
if (is_multi_author()) {
echo "This site has multiple authors.";
} else {
echo "This site has only one author.";
}
Output:
This site has multiple authors.
Parameters
- None
More information
See WordPress Developer Resources: is_multi_author()
Examples
Display a message based on the number of authors
This example checks if the site has multiple authors and displays a message accordingly.
if (is_multi_author()) {
echo "Welcome to our multi-author blog!";
} else {
echo "Welcome to our single-author blog!";
}
Show author list only on multi-author sites
This example displays a list of authors only if the site has multiple authors.
if (is_multi_author()) {
wp_list_authors();
}
Add a CSS class to the body tag
This example adds a ‘group-blog’ CSS class to the body tag on multi-author sites.
function add_group_blog_class($classes) {
if (is_multi_author()) {
$classes[] = 'group-blog';
}
return $classes;
}
add_filter('body_class', 'add_group_blog_class');
Show different widgets based on the number of authors
This example shows different widgets in the sidebar for single-author and multi-author sites.
if (is_multi_author()) {
dynamic_sidebar('multi-author-sidebar');
} else {
dynamic_sidebar('single-author-sidebar');
}
Conditionally display post author information
This example displays the post author’s information only on multi-author sites.
if (is_multi_author()) {
echo "Posted by ";
the_author_posts_link();
}