wpseek.com
A WordPress-centric search engine for devs and theme authors



is_random › WordPress Function

Since7.2.0
Deprecatedn/a
› is_random ( No parameters )
See:
Returns:
  • (bool) Whether the query is for random content.
Defined at:
Codex:

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/.


Source

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();
}