From ea7cb7118cab96f2300be817f0f07af19eba0020 Mon Sep 17 00:00:00 2001 From: Fellan-91 Date: Thu, 21 Dec 2023 16:39:37 +0300 Subject: [PATCH] added a check for an existing portfolio page when trying to create a new archive page If, after importing the demo, an archive portfolio page has already been added, then there is no need to create it again. You just need to add it to the option and define it in the plugin as an archive page --- classes/class-archive-mapping.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/class-archive-mapping.php b/classes/class-archive-mapping.php index 2abd0be1..fdafa951 100644 --- a/classes/class-archive-mapping.php +++ b/classes/class-archive-mapping.php @@ -1065,8 +1065,8 @@ public static function create_archive_page( $custom_slug = 'portfolio' ) { 'post_name' => $custom_slug, ); - // Insert the post into the database. - $post_id = wp_insert_post( $args ); + // Check page if Archive Exist and set as Portfolio page or Insert the post into the database. + $post_id = self::get_unset_archive_page() ?? wp_insert_post( $args ); if ( ! is_wp_error( $post_id ) ) {