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



wp_random_content_split_the_query › WordPress Function

Since7.2.0
Deprecatedn/a
› wp_random_content_split_the_query ( $split_the_query, $query )
Parameters: (2)
  • (bool) $split_the_query Whether or not to split the query.
    Required: Yes
  • (WP_Query) $query The WP_Query instance.
    Required: Yes
Returns:
  • (bool) Whether or not to split the query.
Defined at:
Codex:

Prevents the random content query from being split into multiple database queries.

Randomly ordered queries are not cached, so there is no benefit to querying the post IDs separately to the post objects. Disabling the split allows the random post to be retrieved in a single database query.


Source

function wp_random_content_split_the_query( $split_the_query, WP_Query $query ): bool {
	if ( wp_is_random_content_query( $query ) ) {
		return false;
	}

	return (bool) $split_the_query;
}