is_multi_author() WordPress Function

The is_multi_author() function is used to check if a post has more than one author.

is_multi_author() #

Determines whether this site has more than one author.


Description

Checks to see if more than one author has published posts.

For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.


Top ↑

Return

(bool) Whether or not we have more than one author


Top ↑

Source

File: wp-includes/author-template.php

function is_multi_author() {
	global $wpdb;

	$is_multi_author = get_transient( 'is_multi_author' );
	if ( false === $is_multi_author ) {
		$rows            = (array) $wpdb->get_col( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 2" );
		$is_multi_author = 1 < count( $rows ) ? 1 : 0;
		set_transient( 'is_multi_author', $is_multi_author );
	}

	/**
	 * Filters whether the site has more than one author with published posts.
	 *
	 * @since 3.2.0
	 *
	 * @param bool $is_multi_author Whether $is_multi_author should evaluate as true.
	 */
	return apply_filters( 'is_multi_author', (bool) $is_multi_author );
}


Top ↑

Changelog

Changelog
VersionDescription
3.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.