
利用Query Monitor插件调试WordPress并提高网站性能
is_multi_author ( No parameters )
确定这个网站是否有一个以上的作者。
检查是否有一个以上的作者发表过文章。
关于这个和类似主题函数的更多信息,请查看《主题开发者手册》中的{@link Conditional Tags}文章。
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 ); }