I'm using the Flexible Posts Widget to display a list of "deals" (a custom post type) in my sidebar. I'm also using that plugin's capacity to use a custom template to control the display of that listing (see details of how this works on the plugin's installation screen).
One of the meta boxes available in this CPT is a radio button that identifies if the deal is Active or Inactive. On all the "deals" pages (both individual and listings), I've been able to filter the deals so only the "Active" ones show up (like so. However, I can't figure out how to link up with the query run by this plugin and add the ability to exclude deals marked Inactive. I tried using pre_get_posts to this effect, but no luck.
Is it even possible to accomplish this? Or do I need to give up on the plugin and roll my own sidebar query?
In the interim I've added a new WP_Query to the custom template, but understand this is highly inefficient as it pretty much means the query is being run twice. I just haven't been able to get it to work any other way; no luck so far limiting pre_get_posts to just this one query (i.e., not all queries or the main query) or somehow adding in the metakey args after the fact.
<?php // Exclude Inactive Offers from queries $args = array( 'post_type' => 'offers', 'meta_query' => array( array( 'key' => 'offer-status', 'value' => 'Active' ) ), 'posts_per_page' => '3' ); $offers_query = new WP_Query( $args ); ?> <?php while ( $offers_query->have_posts() ) : $offers_query->the_post(); ?>