From ad234eb0459fa0e04b223f0b5248ab73b648918c Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Fri, 25 Oct 2019 14:51:58 -0400 Subject: [PATCH] Restrict any pledges with no contributors from being shown on the frontend --- plugins/wporg-5ftf/includes/pledge.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plugins/wporg-5ftf/includes/pledge.php b/plugins/wporg-5ftf/includes/pledge.php index f1d3f21..2904731 100755 --- a/plugins/wporg-5ftf/includes/pledge.php +++ b/plugins/wporg-5ftf/includes/pledge.php @@ -143,9 +143,23 @@ function filter_query( $query ) { return; } + // Set up meta queries to include the "valid pledge" check, added to both search and any pledge requests. + $meta_queries = (array) $query->get( 'meta_query' ); + $meta_queries[] = array( + 'key' => META_PREFIX . 'org-number-employees', + 'value' => 0, + 'compare' => '>', + 'type' => 'NUMERIC', + ); + + if ( CPT_ID === $query->get( 'post_type' ) ) { + $query->set( 'meta_query', $meta_queries ); + } + // Searching is restricted to pledges only. if ( $query->is_search ) { $query->set( 'post_type', CPT_ID ); + $query->set( 'meta_query', $meta_queries ); } // Use the custom order param to sort the archive page.