Account for story post comments in count

You cannot normally comment on stories, only chapters, but in case someone changes that for likely no good reason, these comments are now also counted.
This commit is contained in:
Tetrakern 2024-12-18 00:41:18 +01:00
parent 96f7cf4b66
commit c57950a65d

View File

@ -430,7 +430,8 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
$meta_cache['comment_count_timestamp'] = time();
// Update post database comment count
fictioneer_sql_update_comment_count( $story_id, $comment_count );
$story_comment_count = get_approved_comments( $story_id, array( 'count' => true ) ) ?: 0;
fictioneer_sql_update_comment_count( $story_id, $comment_count + $story_comment_count );
// Update meta cache and purge
update_post_meta( $story_id, 'fictioneer_story_data_collection', $meta_cache );
@ -583,7 +584,8 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
update_post_meta( $story_id, 'fictioneer_story_total_word_count', $word_count );
// Update post database comment count
fictioneer_sql_update_comment_count( $story_id, $comment_count );
$story_comment_count = get_approved_comments( $story_id, array( 'count' => true ) ) ?: 0;
fictioneer_sql_update_comment_count( $story_id, $comment_count + $story_comment_count );
// Done
return $result;