' . esc_html__('Your demo import has been completed successfully.', 'bb-mobile-application') . '
'; echo '' . esc_html__('VIEW SITE', 'bb-mobile-application') . ''; //end // Slider set_theme_mod( 'bb_mobile_application_banner_left_img', get_template_directory_uri().'/images/image1.png' ); set_theme_mod( 'bb_mobile_application_slider_small_title', 'Lorem ipsum dol consectetur adipiscing' ); for($bb_mobile_application_i=1;$bb_mobile_application_i<=4;$bb_mobile_application_i++){ $bb_mobile_application_slider_title = 'LOREM IPSUM IPIS'; $bb_mobile_application_slider_content = 'Lorem ipsum dolor sit amet, consectetur adi.'; // Create post object $bb_mobile_application_my_post = array( 'post_title' => wp_strip_all_tags( $bb_mobile_application_slider_title ), 'post_content' => $bb_mobile_application_slider_content, 'post_status' => 'publish', 'post_type' => 'page', ); // Insert the post into the database $bb_mobile_application_post_id = wp_insert_post( $bb_mobile_application_my_post ); if ($bb_mobile_application_post_id) { // Set the theme mod for the slider page set_theme_mod('bb_mobile_application_slider' . $bb_mobile_application_i, $bb_mobile_application_post_id); $bb_mobile_application_image_url = get_template_directory_uri().'/images/slider'.$bb_mobile_application_i.'.png'; $bb_mobile_application_image_id = media_sideload_image($bb_mobile_application_image_url, $bb_mobile_application_post_id, null, 'id'); if (!is_wp_error($bb_mobile_application_image_id)) { // Set the downloaded image as the post's featured image set_post_thumbnail($bb_mobile_application_post_id, $bb_mobile_application_image_id); } } } // Creative Features Section set_theme_mod( 'bb_mobile_application_title', 'Lorem ipsum dolor' ); // Post Category set_theme_mod( 'bb_mobile_application_blogcategory_left_setting', 'category1' ); set_theme_mod( 'bb_mobile_application_blogcategory_right_setting', 'category2' ); // Define post category names and post titles $bb_mobile_application_category_names = array('category1', 'category2'); $bb_mobile_application_title_array = array( array("Lorem ipsum 1", "Lorem ipsum 2"), array("Lorem ipsum 3", "Lorem ipsum 4") ); $bb_mobile_application_image_counter = 1; // Counter to ensure unique images foreach ($bb_mobile_application_category_names as $bb_mobile_application_index => $bb_mobile_application_category_name) { // Create or retrieve the post category term ID $bb_mobile_application_term = term_exists($bb_mobile_application_category_name, 'category'); if ($bb_mobile_application_term === 0 || $bb_mobile_application_term === null) { // If the term does not exist, create it $bb_mobile_application_term = wp_insert_term($bb_mobile_application_category_name, 'category'); } if (is_wp_error($bb_mobile_application_term)) { error_log('Error creating category: ' . $bb_mobile_application_term->get_error_message()); continue; // Skip to the next iteration if category creation fails } for ($bb_mobile_application_i = 0; $bb_mobile_application_i < 2; $bb_mobile_application_i++) { // Create post content $bb_mobile_application_title = $bb_mobile_application_title_array[$bb_mobile_application_index][$bb_mobile_application_i]; $bb_mobile_application_content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'; // Create post post object $bb_mobile_application_my_post = array( 'post_title' => wp_strip_all_tags($bb_mobile_application_title), 'post_content' => $bb_mobile_application_content, 'post_status' => 'publish', 'post_type' => 'post', // Post type set to 'post' ); // Insert the post into the database $bb_mobile_application_post_id = wp_insert_post($bb_mobile_application_my_post); if (is_wp_error($bb_mobile_application_post_id)) { error_log('Error creating post: ' . $bb_mobile_application_post_id->get_error_message()); continue; // Skip to the next post if creation fails } // Assign the category to the post wp_set_post_categories($bb_mobile_application_post_id, array((int)$bb_mobile_application_term['term_id'])); // Handle the featured image using media_sideload_image $bb_mobile_application_image_url = get_template_directory_uri() . '/images/post-image' . $bb_mobile_application_image_counter . '.png'; $bb_mobile_application_image_id = media_sideload_image($bb_mobile_application_image_url, $bb_mobile_application_post_id, null, 'id'); if (is_wp_error($bb_mobile_application_image_id)) { error_log('Error downloading image: ' . $bb_mobile_application_image_id->get_error_message()); continue; // Skip to the next post if image download fails } // Assign featured image to post set_post_thumbnail($bb_mobile_application_post_id, $bb_mobile_application_image_id); $bb_mobile_application_image_counter++; // Increment the image counter for unique images } } // Single Post $bb_mobile_application_post_title = 'Lorem Ipsum is simply dummy'; $bb_mobile_application_post_content = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.'; // Create post object $bb_mobile_application_my_post = array( 'post_title' => wp_strip_all_tags($bb_mobile_application_post_title), 'post_content' => $bb_mobile_application_post_content, 'post_status' => 'publish', 'post_type' => 'post', ); // Insert the post into the database $bb_mobile_application_post_id = wp_insert_post($bb_mobile_application_my_post); // Check if the post was successfully created if (!is_wp_error($bb_mobile_application_post_id)) { // Set the theme mod for the post ID set_theme_mod('bb_mobile_application_middle_image_setting', $bb_mobile_application_post_id); // Fetch the image URL $bb_mobile_application_image_url = get_template_directory_uri() . '/images/image.png'; // Media sideload the image $bb_mobile_application_image_id = media_sideload_image($bb_mobile_application_image_url, $bb_mobile_application_post_id, null, 'id'); // Check if the image was successfully uploaded if (!is_wp_error($bb_mobile_application_image_id)) { // Set the downloaded image as the post's featured image set_post_thumbnail($bb_mobile_application_post_id, $bb_mobile_application_image_id); } else { // Handle the error if the image upload failed error_log('Image upload failed: ' . $bb_mobile_application_image_id->get_error_message()); } } else { // Handle the error if the post creation failed error_log('Post creation failed: ' . $bb_mobile_application_post_id->get_error_message()); } } ?>