lp__post_featured
lp__post_featured is a custom query parameter in the Launchpad Core plugin that allows you to filter and retrieve posts marked as “featured.” Unlike the standard approach of using post meta (wp_postmeta), Launchpad Core stores this information in a custom database table instead of the WordPress postmeta table.
Product
How it Works
In Launchpad Core and dependent plugins like Malcolm, custom post types (CPTs) are registered using the LP__CPT object. This object provides various functionalities, including the ability to mark posts as featured.
Because the featured status is stored in a custom table rather than wp_postmeta, the lp__post_featured parameter enables optimized filtering without requiring meta_query. It works seamlessly within WP_Query, allowing you to retrieve featured posts efficiently while still supporting WordPress’ built-in query parameters.
Accepted Values
lp__post_featured accepts boolean-like values:
true(1 – integer): Includes only posts marked as “featured.”false(0 – integer): Includes only posts that are not marked as “featured.
Usage
You can use lp__post_featured in your code to filter and retrieve posts that are marked as featured. This parameter acts as a binary flag, allowing you to determine whether posts should be included in the query based on their featured status.
Example
$args = array(
'post_type' => 'rep_listing', // Replace with your actual custom post type.
'lp__post_featured' => true, // Retrieve only featured posts.
);
$query = new WP_Query( $args );
In this example, the query will return a list of posts of the ‘rep_listing’ post type where the ‘featured’ custom field is set to ‘true’. These are the posts that are marked as featured in your custom post type.
Result
| The result of the query in the provided example will be a list of posts of the ‘rep_listing’ post type where the ‘featured’ custom field is set to ‘true’. |