diff --git a/includes/functions/_development.php b/includes/functions/_development.php index 9b83bd18..dfc4dd9e 100644 --- a/includes/functions/_development.php +++ b/includes/functions/_development.php @@ -62,6 +62,8 @@ function fictioneer_generate_test_comments( $post_id, $number = 3 ) { */ function fictioneer_generate_test_content() { + global $wpdb; + if ( ! current_user_can( 'manage_options' ) || get_current_user_id() !== 1 || ! WP_DEBUG ) { return; } @@ -158,6 +160,14 @@ function fictioneer_generate_test_content() { fictioneer_generate_test_comments( $chapter_id, $comment_count ); update_post_meta( $chapter_id, 'fictioneer_chapter_story', $story_id ); + + $wpdb->query( + $wpdb->prepare( + "UPDATE {$wpdb->posts} SET post_parent = %d WHERE ID = %d", + $story_id ?: 0, + $chapter_id + ) + ); } } diff --git a/includes/functions/_setup-meta-fields.php b/includes/functions/_setup-meta-fields.php index 10819ef6..22a4c375 100644 --- a/includes/functions/_setup-meta-fields.php +++ b/includes/functions/_setup-meta-fields.php @@ -3051,6 +3051,16 @@ function fictioneer_save_chapter_metaboxes( $post_id ) { if ( get_option( 'fictioneer_enable_chapter_appending' ) ) { fictioneer_append_chapter_to_story( $post_id, $story_id ); } + + global $wpdb; + + $wpdb->query( + $wpdb->prepare( + "UPDATE {$wpdb->posts} SET post_parent = %d WHERE ID = %d", + $story_id ?: 0, + $post_id + ) + ); } }