From 8f69169e6df7efee88a7f59ea0f8c675f5073497 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Sun, 3 Nov 2024 13:48:46 +0100 Subject: [PATCH] Restore excluded chapter post fields after query This is to prevent errors if something tries to access the excluded fields, which would be null otherwise. --- includes/functions/_utility.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/includes/functions/_utility.php b/includes/functions/_utility.php index 8ee56438..47457618 100644 --- a/includes/functions/_utility.php +++ b/includes/functions/_utility.php @@ -300,10 +300,19 @@ function fictioneer_get_story_chapter_posts( $story_id, $args = [], $full = fals return $chapter_positions[ $a->ID ] - $chapter_positions[ $b->ID ]; }); - // Add note about missing content + // Add note about missing content and restore all fields to avoid errors if ( ! $full ) { foreach ( $chapter_posts as $post ) { $post->post_content = 'Caller: fictioneer_get_story_chapter_posts(). Content has been removed for performance reasons.'; + $post->post_type = 'fcn_chapter'; + $post->ping_status = 'closed'; + $post->to_ping = ''; + $post->pinged = ''; + $post->menu_order = 0; + $post->post_mime_type = ''; + $post->post_content_filtered = ''; + $post->guid = ''; + $post->post_excerpt = ''; } }