On this page
get_meta_sql( array $meta_query, string $type, string $primary_table, string $primary_id_column, object $context = null ): string[]|false
Given a meta query, generates SQL clauses to be appended to a main query.
Description
See also
Parameters
$meta_queryarray Required-
A meta query.
$typestring Required-
Type of meta.
$primary_tablestring Required-
Primary database table name.
$primary_id_columnstring Required-
Primary ID column name.
$contextobject Optional-
The main query object
Default:
null
Return
string[]|false Array containing JOIN and WHERE SQL clauses to append to the main query, or false if no table exists for the requested meta type.
joinstringSQL fragment to append to the main JOIN clause.wherestringSQL fragment to append to the main WHERE clause.
Source
File: wp-includes/meta.php. View all references
function get_meta_sql( $meta_query, $type, $primary_table, $primary_id_column, $context = null ) {
$meta_query_obj = new WP_Meta_Query( $meta_query );
return $meta_query_obj->get_sql( $type, $primary_table, $primary_id_column, $context );
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Meta_Query::__construct() wp-includes/class-wp-meta-query.php | Constructor. |
Changelog
| Version | Description |
|---|---|
| 3.2.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_meta_sql