get_most_active_blogs

函数
get_most_active_blogs ( $num = 10, $display = true )
参数
  • (int) $num Optional. Number of activate blogs to retrieve. Default 10.
    Required:
    Default: 10
  • (bool) $display Optional. Whether or not to display the most active blogs list. Default true.
    Required:
    Default: true
返回值
  • (array) List of "most active" sites.
定义位置
相关方法
get_active_blog_for_userget_post_timeget_post_classget_post_datetimeget_post_field
引入
-
弃用
3.0.0

get_most_active_blogs函数用于检索WordPress多站点安装中最活跃的博客的数组。此功能可用于显示网站上最受欢迎的博客列表。

检索最活跃网站列表的功能已经过时。

function get_most_active_blogs( $num = 10, $display = true ) {
	_deprecated_function( __FUNCTION__, '3.0.0' );

	$blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details
	if ( is_array( $blogs ) ) {
		reset( $blogs );
		$most_active = array();
		$blog_list = array();
		foreach ( (array) $blogs as $key => $details ) {
			$most_active[ $details['blog_id'] ] = $details['postcount'];
			$blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!
		}
		arsort( $most_active );
		reset( $most_active );
		$t = array();
		foreach ( (array) $most_active as $key => $details ) {
			$t[ $key ] = $blog_list[ $key ];
		}
		unset( $most_active );
		$most_active = $t;
	}

	if ( $display ) {
		if ( is_array( $most_active ) ) {
			reset( $most_active );
			foreach ( (array) $most_active as $key => $details ) {
				$url = esc_url('http://' . $details['domain'] . $details['path']);
				echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>";
			}
		}
	}
	return array_slice( $most_active, 0, $num );
}

常见问题

FAQs
查看更多 >