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



wp_random_content_posts_orderby › WordPress Function

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

Orders the random content query randomly.

Added to the 'posts_orderby'} filter by {@see WP::handle_random while the random content query runs. Enforcing the order in SQL prevents {@see 'pre_get_posts'} callbacks setting the order of posts on archives from affecting the selection.


Źródło

function wp_random_content_posts_orderby( $orderby, WP_Query $query ): string {
	if ( wp_is_random_content_query( $query ) ) {
		return 'RAND()';
	}

	return (string) $orderby;
}