array( 'order' => 0, 'content' => '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '', ), 'About Us' => array( 'order' => 1, 'content' => '

We are on a mission to bring scalable artificial intelligence to modern marketing workflows.

' . "\n" . '' . "\n" . '', ), 'Services' => array( 'order' => 2, 'content' => '' . "\n" . '' . "\n" . '', ), 'Contact Us' => array( 'order' => 4, 'content' => '

Reach out to our sales and support engineering team any time at support@example.com.

' . "\n" . '' . "\n" . '', ), ); $homepage_id = 0; foreach ( $pages_to_create as $title => $data ) { $query = new WP_Query( array( 'post_type' => 'page', 'title' => $title, 'post_status' => 'all', 'posts_per_page' => 1, 'no_found_rows' => true, 'ignore_sticky_posts' => true, ) ); $existing_page = ! empty( $query->posts ) ? $query->posts[0] : null; if ( ! $existing_page ) { $page_id = wp_insert_post( array( 'post_title' => sanitize_text_field( $title ), 'post_content' => $data['content'], 'post_status' => 'publish', 'post_type' => 'page', 'menu_order' => $data['order'], ) ); if ( 'Home' === $title && ! is_wp_error( $page_id ) ) { $homepage_id = $page_id; } } elseif ( 'Home' === $title ) { $homepage_id = $existing_page->ID; } } // Also create a Blog page optionally $blog_query = new WP_Query( array( 'post_type' => 'page', 'title' => 'Blog', 'post_status' => 'all', 'posts_per_page' => 1, 'no_found_rows' => true, 'ignore_sticky_posts' => true, ) ); $blogpage = ! empty( $blog_query->posts ) ? $blog_query->posts[0] : null; $blogpage_id = 0; if ( ! $blogpage ) { $blogpage_id = wp_insert_post( array( 'post_title' => 'Blog', 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'page', 'menu_order' => 3, ) ); } else { $blogpage_id = $blogpage->ID; } // Update reading settings to use the static front page and blog page update_option( 'show_on_front', 'page' ); if ( $homepage_id ) { update_option( 'page_on_front', $homepage_id ); } if ( $blogpage_id && ! is_wp_error( $blogpage_id ) ) { update_option( 'page_for_posts', $blogpage_id ); } // Generate 15 dummy blog posts bharat_ai_generate_demo_posts(); } } if ( ! function_exists( 'bharat_ai_generate_demo_posts' ) ) { /** * Generates 15 dummy blog posts. */ function bharat_ai_generate_demo_posts() { for ( $i = 1; $i <= 15; $i++ ) { $title = "Sample Blog Post $i"; $query = new WP_Query( array( 'post_type' => 'post', 'title' => $title, 'post_status' => 'all', 'posts_per_page' => 1, 'no_found_rows' => true, 'ignore_sticky_posts' => true, ) ); if ( empty( $query->posts ) ) { wp_insert_post( array( 'post_title' => $title, 'post_content' => '

This is a sample blog post generated by Bharat AI Marketing theme activation. It helps demonstrate the layout and pagination of your new AI-powered blog.

', 'post_status' => 'publish', 'post_type' => 'post', ) ); } } } }