lp__meta_key
lp__meta_key is a custom query parameter in the Launchpad Core plugin that allows you to order query results based on a specific custom meta key. It functions similarly to WordPress’s built-in meta_key parameter but is optimized for Launchpad Core’s custom data storage approach.
Product
How it Works
In WordPress, meta_key is typically used with meta_query to filter and order posts based on custom field values stored in the wp_postmeta table. Launchpad Core enhances this functionality by introducing an optimized custom table for structured data storage.
The lp__meta_key parameter allows ordering query results based on custom fields while working alongside standard WordPress functionalities like meta_query. This enables efficient sorting and filtering without the performance overhead of meta queries.
Accepted Values
lp__meta_key accepts a single string value, which represents the custom field key (meta key) to use for ordering the query results.
Usage
You can use lp__meta_key in your custom code to determine the meta key by which you want to order your query results. This parameter affects the ‘ORDER BY’ clause of the main query, enabling you to specify a custom meta key for sorting posts.
Example
$query_args = array(
'post_type' => 'rep_listing', // Replace with your actual custom post type
'lp__meta_key' => 'bedrooms' // Orders listings by the number of property bedrooms
);
// Create a new instance of WP_Query with the defined arguments
new WP_Query( $query_args );
In the example code, we’re using WP_Query to retrieve posts with specific criteria. We’ve included the custom Launchpad meta key, lp__meta_key, set to bedrooms. This allows us to order the query results based on the number of bedrooms associated with each listing.
Result
If you use lp__meta_key in a query with the specified custom field key, it will return posts ordered by that custom meta key. This enables sorting based on specific fields, such as the number of bedrooms in a real estate listing. |