Also set story as post parent for chapters

For the future.
This commit is contained in:
Tetrakern 2024-10-26 20:05:08 +02:00
parent ac6a2422de
commit 713cf7db06
2 changed files with 20 additions and 0 deletions

View File

@ -62,6 +62,8 @@ function fictioneer_generate_test_comments( $post_id, $number = 3 ) {
*/ */
function fictioneer_generate_test_content() { function fictioneer_generate_test_content() {
global $wpdb;
if ( ! current_user_can( 'manage_options' ) || get_current_user_id() !== 1 || ! WP_DEBUG ) { if ( ! current_user_can( 'manage_options' ) || get_current_user_id() !== 1 || ! WP_DEBUG ) {
return; return;
} }
@ -158,6 +160,14 @@ function fictioneer_generate_test_content() {
fictioneer_generate_test_comments( $chapter_id, $comment_count ); fictioneer_generate_test_comments( $chapter_id, $comment_count );
update_post_meta( $chapter_id, 'fictioneer_chapter_story', $story_id ); 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
)
);
} }
} }

View File

@ -3051,6 +3051,16 @@ function fictioneer_save_chapter_metaboxes( $post_id ) {
if ( get_option( 'fictioneer_enable_chapter_appending' ) ) { if ( get_option( 'fictioneer_enable_chapter_appending' ) ) {
fictioneer_append_chapter_to_story( $post_id, $story_id ); 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
)
);
} }
} }