Pledge CPT: Remove "has contributors" check from the single pledge view

This commit is contained in:
Kelly Dwan 2019-10-29 18:09:44 -05:00
parent 1c6d39cd2a
commit 9f47f83ef4
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D

View file

@ -184,7 +184,7 @@ function filter_query( $query ) {
$contributor_count_key = META_PREFIX . 'pledge-confirmed-contributors'; $contributor_count_key = META_PREFIX . 'pledge-confirmed-contributors';
// Set up meta queries to include the "valid pledge" check, added to both search and any pledge requests. // Set up meta queries to include the "valid pledge" check, added to both search and pledge archive requests.
$meta_queries = (array) $query->get( 'meta_query' ); $meta_queries = (array) $query->get( 'meta_query' );
$meta_queries[] = array( $meta_queries[] = array(
'key' => $contributor_count_key, 'key' => $contributor_count_key,
@ -193,11 +193,7 @@ function filter_query( $query ) {
'type' => 'NUMERIC', 'type' => 'NUMERIC',
); );
if ( CPT_ID === $query->get( 'post_type' ) ) { // Searching is restricted to pledges with contributors only.
$query->set( 'meta_query', $meta_queries );
}
// 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 ); $query->set( 'meta_query', $meta_queries );
@ -205,6 +201,8 @@ function filter_query( $query ) {
// Use the custom order param to sort the archive page. // Use the custom order param to sort the archive page.
if ( $query->is_archive && CPT_ID === $query->get( 'post_type' ) ) { if ( $query->is_archive && CPT_ID === $query->get( 'post_type' ) ) {
// Archives should only show pledges with contributors.
$query->set( 'meta_query', $meta_queries );
$order = isset( $_GET['order'] ) ? $_GET['order'] : ''; $order = isset( $_GET['order'] ) ? $_GET['order'] : '';
switch ( $order ) { switch ( $order ) {
case 'alphabetical': case 'alphabetical':