From 07c76a9d35ed840bc6709d05e4dafdb6cbac0985 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Fri, 16 Jun 2023 02:07:03 +0200 Subject: [PATCH] Let collections ignore hidden stories --- partials/_collection-statistics.php | 5 +++++ single-fcn_collection.php | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/partials/_collection-statistics.php b/partials/_collection-statistics.php index 859a167b..d600cdb2 100644 --- a/partials/_collection-statistics.php +++ b/partials/_collection-statistics.php @@ -47,6 +47,11 @@ if ( ! empty( $args['featured_list'] ) ) { $processed_ids[] = $post_id; } } elseif ( $post_type == 'fcn_story' ) { + // Skip hidden stories + if ( fictioneer_get_field( 'fictioneer_story_hidden', $post_id ) ) { + continue; + } + $story = fictioneer_get_story_data( $post_id ); $story_count += 1; diff --git a/single-fcn_collection.php b/single-fcn_collection.php index b83ba6aa..790350be 100644 --- a/single-fcn_collection.php +++ b/single-fcn_collection.php @@ -32,7 +32,7 @@ $featured_list = empty( $featured_list ) ? [] : $featured_list; $title = fictioneer_get_safe_title( $post->ID ); $this_breadcrumb = [$title, get_the_permalink()]; - $current_page = max( 1, get_query_var( 'pg', 1 ) ); // Paged not available + $current_page = max( 1, get_query_var( 'pg', 1 ) ?: 1 ); // Paged not available // Clean featured list of unwanted entries foreach ( $featured_list as $key => $post_id ) { @@ -49,7 +49,18 @@ 'orderby' => 'modified', 'order' => 'DESC', 'paged' => $current_page, - 'posts_per_page' => get_option( 'posts_per_page', 8 ) + 'posts_per_page' => get_option( 'posts_per_page', 8 ), + 'meta_query' => array( + 'relation' => 'OR', + array( + 'key' => 'fictioneer_story_hidden', + 'value' => '0' + ), + array( + 'key' => 'fictioneer_story_hidden', + 'compare' => 'NOT EXISTS' + ), + ) ); // Query featured posts