wppaste
WordPress

WP_Meta_Query

Since
3.2.0
Source
wp-includes/class-wp-meta-query.php:22
Core class used to implement meta queries for the Meta API.

Description

Used for generating SQL clauses that filter a primary query according to metadata keys and values.

WP_Meta_Query is a helper that allows primary query classes, such as WP_Query and WP_User_Query,

to filter their results by object metadata, by generating JOIN and WHERE subclauses to be attached to the primary SQL query string.

Compatibility

WordPress
since 3.2.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 2

Every hook that fires from inside WP_Meta_Query, in the order it appears in the class, grouped by the method that fires it.

Properties · 9

$queriesarraypublic
Array of metadata queries.
$relationstringpublic
The relation between the queries. Can be one of 'AND' or 'OR'.
$meta_tablestringpublic
Database table to query for the metadata.
$meta_id_columnstringpublic
Column in meta_table that represents the ID of the object the metadata belongs to.
$primary_tablestringpublic
Database table that where the metadata's objects are stored (eg $wpdb->users).
$primary_id_columnstringpublic
Column in primary_table that represents the ID of the object.
$table_aliasesarrayprotected
A flat list of table aliases used in JOIN clauses.
$clausesarrayprotected
A flat list of clauses, keyed by clause 'name'.
$has_or_relationboolprotected
Whether the query contains any OR relations.

Methods · 12

Source code

#[AllowDynamicProperties]class WP_Meta_Query {	/**	 * Array of metadata queries.	 *	 * See WP_Meta_Query::__construct() for information on meta query arguments.	 *	 * @since 3.2.0	 * @var array	 */	public $queries = array(); 	/**	 * The relation between the queries. Can be one of 'AND' or 'OR'.	 *	 * @since 3.2.0	 * @var string	 */	public $relation; 	/**	 * Database table to query for the metadata.	 *	 * @since 4.1.0	 * @var string	 */	public $meta_table; 	/**	 * Column in meta_table that represents the ID of the object the metadata belongs to.	 *	 * @since 4.1.0	 * @var string	 */	public $meta_id_column; 	/**	 * Database table that where the metadata's objects are stored (eg $wpdb->users).	 *	 * @since 4.1.0	 * @var string	 */	public $primary_table; 	/**	 * Column in primary_table that represents the ID of the object.	 *	 * @since 4.1.0	 * @var string	 */	public $primary_id_column; 	/**	 * A flat list of table aliases used in JOIN clauses.	 *	 * @since 4.1.0	 * @var array	 */	protected $table_aliases = array(); 	/**	 * A flat list of clauses, keyed by clause 'name'.	 *	 * @since 4.2.0	 * @var array	 */	protected $clauses = array(); 	/**	 * Whether the query contains any OR relations.	 *	 * @since 4.3.0	 * @var bool	 */	protected $has_or_relation = false; 	/**	 * Constructor.	 *	 * @since 3.2.0

Changelog

Introduced in 3.2.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/class-wp-meta-query.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.