wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_random_content_post_limits › WordPress Function

Od7.2.0
Przestarzałyn/a
› wp_random_content_post_limits ( $limits, $query )
Parametry: (2)
  • (string) $limits The LIMIT clause of the query.
    Wymagane: Tak
  • (WP_Query) $query The WP_Query instance.
    Wymagane: Tak
Powrót:
  • (string) The LIMIT clause of the query.
Zdefiniowane na:
Codex:

Limits the random content query to a single post.

Added to the 'post_limits'} filter by {@see WP::handle_random while the random content query runs. Enforcing the limit in SQL prevents {@see 'pre_get_posts'} callbacks setting the number of posts, offset or page on archives from affecting the selection.


Źródło

function wp_random_content_post_limits( $limits, WP_Query $query ): string {
	if ( wp_is_random_content_query( $query ) ) {
		return 'LIMIT 0, 1';
	}

	return (string) $limits;
}