get_meta_sql( array $meta_query, string $type, string $primary_table, string $primary_id_column, object $context = null )
Given a meta query, generates SQL clauses to be appended to a main query.
Description Description
See also See also
Parameters Parameters
- $meta_query
-
(array) (Required) A meta query.
- $type
-
(string) (Required) Type of meta.
- $primary_table
-
(string) (Required) Primary database table name.
- $primary_id_column
-
(string) (Required) Primary ID column name.
- $context
-
(object) (Optional) The main query object
Default value: null
Return Return
(array) Associative array of JOIN and WHERE SQL.
Source Source
File: wp-includes/meta.php
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 );
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 3.2.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Example
Output depending on the meta query:
Array ( [join] => INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) [where] => AND ( (wp_postmeta.meta_key = 'color' AND CAST(wp_postmeta.meta_value AS CHAR) NOT LIKE '%blue%') ) )