Restrict any pledges with no contributors from being shown on the frontend

This commit is contained in:
Kelly Dwan 2019-10-25 14:51:58 -04:00
parent 85b8b38ed0
commit ad234eb045
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D

View file

@ -143,9 +143,23 @@ function filter_query( $query ) {
return; 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. // Searching is restricted to pledges only.
if ( $query->is_search ) { if ( $query->is_search ) {
$query->set( 'post_type', CPT_ID ); $query->set( 'post_type', CPT_ID );
$query->set( 'meta_query', $meta_queries );
} }
// Use the custom order param to sort the archive page. // Use the custom order param to sort the archive page.