From bb827ec1ef262c55a6cf8421845c15f4b2de3471 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Sun, 12 Jan 2025 23:37:52 +0100 Subject: [PATCH] Allow latest chapters to be standalone --- partials/_latest-chapters-compact.php | 2 +- partials/_latest-chapters-list.php | 10 +++++----- partials/_latest-chapters.php | 9 +++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/partials/_latest-chapters-compact.php b/partials/_latest-chapters-compact.php index b3b80240..1064ac11 100644 --- a/partials/_latest-chapters-compact.php +++ b/partials/_latest-chapters-compact.php @@ -157,7 +157,7 @@ if ( $splide ) { $post_id = $post->ID; $story_id = fictioneer_get_chapter_story_id( $post_id ); - if ( get_post_status( $story_id ) !== 'publish' ) { + if ( $story_id && get_post_status( $story_id ) !== 'publish' ) { continue; } diff --git a/partials/_latest-chapters-list.php b/partials/_latest-chapters-list.php index bdcf64fd..f11dddd5 100644 --- a/partials/_latest-chapters-list.php +++ b/partials/_latest-chapters-list.php @@ -161,9 +161,8 @@ if ( $splide ) { // Setup $post_id = $post->ID; $story_id = fictioneer_get_chapter_story_id( $post_id ); - $story = $story_id ? fictioneer_get_story_data( $story_id, false ) : null; // Does not refresh comment count! - if ( get_post_status( $story_id ) !== 'publish' || ! $story ) { + if ( $story_id && get_post_status( $story_id ) !== 'publish' ) { continue; } @@ -174,11 +173,12 @@ if ( $splide ) { // Continue setup $title = fictioneer_get_safe_title( $post_id, 'shortcode-latest-chapters-list' ); + $story = $story_id ? fictioneer_get_story_data( $story_id, false ) : null; // Does not refresh comment count! $permalink = get_permalink( $post_id ); $chapter_rating = get_post_meta( $post_id, 'fictioneer_chapter_rating', true ); $words = fictioneer_get_word_count( $post_id ); - if ( ! $chapter_rating && $story_id ) { + if ( ! $chapter_rating && $story ) { $chapter_rating = get_post_meta( $story_id, 'fictioneer_story_rating', true ); } @@ -250,7 +250,7 @@ if ( $splide ) { // Meta $meta = []; - if ( $args['source'] ) { + if ( $story && $args['source'] ) { $meta['story'] = sprintf( _x( '
', @@ -269,7 +269,7 @@ if ( $splide ) { ) . ''; } - if ( $args['footer_status'] ) { + if ( $story && $args['footer_status'] ) { $meta['status'] = ' '; } diff --git a/partials/_latest-chapters.php b/partials/_latest-chapters.php index 04ef14b3..3a94e278 100644 --- a/partials/_latest-chapters.php +++ b/partials/_latest-chapters.php @@ -162,18 +162,19 @@ if ( $splide ) { $post_id = $post->ID; $story_id = fictioneer_get_chapter_story_id( $post_id ); - if ( get_post_status( $story_id ) !== 'publish' ) { + if ( $story_id && get_post_status( $story_id ) !== 'publish' ) { continue; } $title = fictioneer_get_safe_title( $post_id, 'shortcode-latest-chapters' ); + $permalink = get_permalink(); $chapter_rating = get_post_meta( $post_id, 'fictioneer_chapter_rating', true ); $story = $story_id ? fictioneer_get_story_data( $story_id, false ) : null; // Does not refresh comment count! $text_icon = get_post_meta( $post_id, 'fictioneer_chapter_text_icon', true ); $grid_or_vertical = $args['vertical'] ? '_vertical' : '_grid'; $card_classes = []; - if ( ! $chapter_rating && $story_id ) { + if ( ! $chapter_rating && $story ) { $chapter_rating = get_post_meta( $story_id, 'fictioneer_story_rating', true ); } @@ -262,7 +263,7 @@ if ( $splide ) { 'post_id' => $post_id, 'title' => $title, 'classes' => 'card__image cell-img', - 'permalink' => get_permalink(), + 'permalink' => $permalink, 'lightbox' => $args['lightbox'], 'vertical' => $args['vertical'], 'seamless' => $args['seamless'], @@ -273,7 +274,7 @@ if ( $splide ) { } ?> -