Wordpress Meta_query

~ Wordpress Meta_Query Meta_Query

In order to filter with user-defined fields, we use the argument meta_query. If you want to query WordPress posts with the parameter meta_query. WorPress meta_query by comparison (value, array, date).

<font color="#ffff00">Description

It is a category specified in wp-includes/meta. php that creates the necessary SQL for meta-related requests. and enhanced the ability to retrieve contributions by user-defined input boxes. If you are not typing a customized SQL request, you should search for the appropriate SQL statement classes in the *Custom Field Parameters* section. You can pass the following argument in a Keys=>Value matched arrowray. xeta_type ( string) - Customizing Field Ty (see below types for options). xeta_compare ( string) - Administrator for testing the'meta_value' (see below comparison for possible values). xeta_query (array) - Contains one or more arrow (s) with the following keys: Keys (string) - Customizing Field Keys. x Value (string|array) - Customizing Field Value.

This can only be an arrays if the comparison is 'IN', 'NOT IN', 'BETWEEN' or 'NOT BETWEEN'. Standard value is'='. Operator defined character chain - User defined character area. Date of Transition only works with the comparison value BETWEEN if the date is saved in YYYYY-MM-DD form and checked with this form.

Hint: The arguments'meta_key','meta_value','meta_type' and'meta_compare' only work if you use the second way described below. In general, you have two ways to initiate and use a new initial program entry meta question object: Transfer an array set of request parameter to the constructor:

If there is more than one subquery (whether all requirements are to be fulfilled or at least one of them must be fulfilled), it will define the relationship.

Value' Value I'm looking for 2', 'compare' => '=' ), 'key' '_my_custom_key_3', 'value' 'value' 'value I'm looking for 3', 'compare' => '=' ); $meta_query = new WP_Meta_Query( $meta_query_args ); using the WP_Meta_Query: If you want to use the basic arguments of the queries (`meta_key`, `meta_value`, `meta_type`, `meta_type`, `meta_compare`) or if you are not sure if there are any available parameter.

Default: $meta_query = new WP_Meta_Query();'meta_key' =>'some_key', // etc. $type' (string) - kind of meta(post, comment, username). primary_id_column (string) - The colum which contains the ID (for contributions it is ID, for annotations it is comments_ID and for custom it is ID). This is the default value for the $context (object) - option - the primary interrogation item. If an error occurs (e.g. if there are no subquery parameter in the queries array) this command returns `false`.

If successful, an arrays like this is returned: metekey' => 'some_key_name', ); $meta_query = new WP_Meta_Query(); $meta_query->parse_query_vars( $query_args); 'post', $wpdb->posts, 'ID', ); Example: Several Meta Entries - Multidimensional Array: Inquiry:: Relationship' => 'OR', 'key' => 'foo_key', // 'value' => 'foo', // 'compare' => 'LIKE', ), 'key' => 'bar_key', ), ), ) ) ) ) );

Default: $meta_query = new WP_Meta_Query(); $meta_query->parse_query_vars( $query_args ); 'post', $wpdb->posts, 'ID', ); Result: Hint: In this example, no spaces are appended to the join instruction, so you must do it manual to avoid crashing your request. When you use the value and comparing parts of the meta_query entry arguments arrays, the request ring looks something like this:

where' => string string ' AND (wp_postmeta. meta_key = 'foo_key' OR (mt1. meta_key = 'bar_key' AND CAST(mt1. AS CHAR) LIKE'%foo%') )' Remember that this is the nickname of the join and the join will look something like this, so use the JOIN twice:'join' => string ' INNER JOIN wp_postmeta ON wp_posts.

Use this in further requests or forms within your posts_clauses, posts_where or posts_join filters to call you back. named subqueries are especially useful if you want to order by several different subkeys.

You can find WP_Meta_Query() in wp-includes/class-wp-meta-query.php.

Mehr zum Thema