wpseek.com
WordPress开发者和主题制作者的搜索引擎



is_random › WordPress Function

Since7.2.0
已弃用n/a
› is_random ( 没有参数 )
查看:
返回:
  • (bool) Whether the query is for random content.
定义在:
文档:

Determines whether the query is for random content.

True for a blog home, archive or search request that includes the random query variable, for example example.com/random/ or example.com/random/category/news/.


源码

function is_random(): bool {
	global $wp_query;

	if ( ! isset( $wp_query ) ) {
		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '7.2.0' );
		return false;
	}

	return $wp_query->is_random();
}