函数原型
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.
是否弃用
未弃用
函数参数
-
$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:
null
函数返回值
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.
函数位置
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 );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 3.2.0 | Introduced. |

