lp__post_query
lp__post_query is a custom query parameter used in the Launchpad plugin to facilitate post queries. This parameter functions as an array container for specifying custom post query conditions, allowing you to filter posts based on various criteria.
Product
How it Works
This parameter allows defining a multi-dimensional array for complex post queries. It supports multiple conditions with logical relationships (AND or OR) and integrates seamlessly with existing query parameters such as post_status, meta_query, etc.
Accepted Arguments
The following arguments can be passed as an array of key-value pairs:
- key (string) – The meta key (custom field key) to filter by.
- value (string|array) – The value to compare against. If
compareisIN,NOT IN,BETWEEN, orNOT BETWEEN, an array must be used. - compare (string) – The comparison operator. Supported values:
>,<,>=,<=,=,<>,LIKE,NOT LIKE,REGEXP,NOT REGEXP, andRLIKE. Default is=. - type (string) – The data type of the custom field. Supported values:
NUMERIC,BINARY,CHAR,DATE,DATETIME,DECIMAL,SIGNED,TIME,UNSIGNED. Default isCHAR. - relation (string) – Defines the logical relationship between multiple conditions. Accepted values:
AND(default) andOR.
Usage
This parameter enables you to define a two dimensional array of post query conditions, including custom field keys, values, comparison operators, and data types. These conditions assist in tailoring your post queries to retrieve posts that match your desired criteria.
Example
$args = array(
'post_type' => 'rep_listing', // Replace with your actual post type.
'lp__post_query' => array(
'relation' => 'AND', // Combine conditions with AND logic
array(
'key' => 'post_title',
'value' => 'example',
'compare' => 'LIKE',
),
array(
'key' => 'post_author',
'value' => 1,
'compare' => '=',
),
),
);
$query = new WP_Query( $args );
In this example, we’ve set ‘lp__post_query‘ in the query arguments to define additional query conditions. The example includes two conditions using the ‘relation’ => ‘AND’ parameter to combine them with an AND logic. You can add more conditions as needed, and the query will retrieve posts that meet all the specified conditions.
Result
This query will retrieve posts of the ‘rep_listing’ post type that match the specified conditions in the lp__post_query. Adjust the conditions and values to fit your requirements. |