On this page
apply_filters_ref_array( 'posts_groupby', string $groupby, WP_Query $query )
Filters the GROUP BY clause of the query.
Parameters
More Information
- If you come with MySQL knowledge, the
GROUP BYclause is pretty useless without the ability to modify theSELECTstatement. - There is no
SELECTfilter since the query is supposed to return only the post data. TheGROUP BYclause is set only when there are Custom Field Parameters for querying by post meta or Taxonomy Parameters for querying by taxonomy. - The default
posts_groupbyis set to{$wpdb->posts}.ID, which means that even if there are multiple results because of multiple meta and taxonomy, they are grouped together by the post id.
Source
File: wp-includes/class-wp-query.php. View all references
$groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this ) );
Related
Used By
| Used By | Description |
|---|---|
| WP_Query::get_posts() wp-includes/class-wp-query.php | Retrieves an array of posts based on query variables. |
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/hooks/posts_groupby