Fix meta queries for non-existing fields

Well, that was to be expected, really. Hope that were all...
This commit is contained in:
Tetrakern 2023-10-03 21:24:44 +02:00
parent f42c2307fe
commit 6b4b1eadb4
6 changed files with 86 additions and 16 deletions

View File

@ -74,12 +74,26 @@ $tabs['chapters'] = array(
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'fictioneer_chapter_hidden',
'value' => '0'
'relation' => 'OR',
array(
'key' => 'fictioneer_chapter_hidden',
'value' => '0'
),
array(
'key' => 'fictioneer_chapter_hidden',
'compare' => 'NOT EXISTS'
)
),
array(
'key' => 'fictioneer_chapter_no_chapter',
'value' => '0'
'relation' => 'OR',
array(
'key' => 'fictioneer_chapter_no_chapter',
'value' => '0'
),
array(
'key' => 'fictioneer_chapter_no_chapter',
'compare' => 'NOT EXISTS'
)
)
)
),

View File

@ -444,12 +444,26 @@ if ( ! function_exists( 'fictioneer_get_author_statistics' ) ) {
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'fictioneer_chapter_hidden',
'value' => '0'
'relation' => 'OR',
array(
'key' => 'fictioneer_chapter_hidden',
'value' => '0'
),
array(
'key' => 'fictioneer_chapter_hidden',
'compare' => 'NOT EXISTS'
)
),
array(
'key' => 'fictioneer_chapter_no_chapter',
'value' => '0'
'relation' => 'OR',
array(
'key' => 'fictioneer_chapter_no_chapter',
'value' => '0'
),
array(
'key' => 'fictioneer_chapter_no_chapter',
'compare' => 'NOT EXISTS'
)
)
),
'update_post_term_cache' => false

View File

@ -73,8 +73,29 @@ if ( ! function_exists( 'fictioneer_build_chapters_schema' ) ) {
'post_type' => 'fcn_chapter',
'post_status' => 'publish',
'meta_query' => array(
array( 'key' => 'fictioneer_chapter_hidden', 'compare' => '=', 'value' => 0, 'type' => 'numeric' ),
array( 'key' => 'fictioneer_chapter_no_chapter', 'compare' => '=', 'value' => 0, 'type' => 'numeric' )
'relation' => 'AND',
array(
'relation' => 'OR',
array(
'key' => 'fictioneer_chapter_hidden',
'value' => '0'
),
array(
'key' => 'fictioneer_chapter_hidden',
'compare' => 'NOT EXISTS'
)
),
array(
'relation' => 'OR',
array(
'key' => 'fictioneer_chapter_no_chapter',
'value' => '0'
),
array(
'key' => 'fictioneer_chapter_no_chapter',
'compare' => 'NOT EXISTS'
)
)
),
'orderby' => 'modified',
'order' => 'DESC',

View File

@ -226,6 +226,7 @@ if ( ! function_exists( 'fictioneer_query_followed_chapters' ) ) {
'post_type' => 'fcn_chapter',
'post_status' => 'publish',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'fictioneer_chapter_story',
'value' => $story_ids,

View File

@ -43,10 +43,20 @@ $query_args = array(
'order' => $args['order'],
'orderby' => $args['orderby'],
'posts_per_page' => $args['count'] + 8, // Little buffer in case of unpublished parent story
'meta_key' => 'fictioneer_chapter_hidden',
'meta_value' => 0,
'no_found_rows' => true,
'update_post_term_cache' => false
'update_post_term_cache' => false,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'fictioneer_chapter_hidden',
'compare' => 'NOT EXISTS'
),
array(
'key' => 'fictioneer_chapter_hidden',
'value' => 0,
'compare' => '='
)
)
);
// Author?

View File

@ -44,10 +44,20 @@ $query_args = array(
'orderby' => $args['orderby'],
'order' => $args['order'],
'posts_per_page' => $args['count'] + 8, // Little buffer in case of unpublished parent story
'meta_key' => 'fictioneer_chapter_hidden',
'meta_value' => 0,
'no_found_rows' => true,
'update_post_term_cache' => false
'update_post_term_cache' => false,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'fictioneer_chapter_hidden',
'compare' => 'NOT EXISTS'
),
array(
'key' => 'fictioneer_chapter_hidden',
'value' => 0,
'compare' => '='
)
)
);
// Author?