Site icon Hip-Hop Website Design and Development

Create default pages in wordpress multisite

I’m struggling with WordPress Multisite page creation when newly site created. I found some hooks to achieve this but the hook is not responding. Some of the resources I found on stack and other sites are https://stackoverflow.com/questions/40014419/wordpress-multisite-default-page-for-newly-created-site and http://www.wpbeginner.com/wp-tutorials/how-to-add-remove-default-pages-in-wordpress-multisite/

The hook mentioned in these resources not working in my multisite setup.

add_action('wpmu_new_blog', 'wpb_create_my_pages', 10, 2);

function wpb_create_my_pages($blog_id, $user_id){
  switch_to_blog($blog_id);

// create new page
  $page_id = wp_insert_post(array(
    'post_title'     => 'About',
    'post_name'      => 'about',
    'post_content'   => 'This is an about page. Feel free to edit or delete this page.',
    'post_status'    => 'publish',
    'post_author'    => $user_id, // or "1" (super-admin?)
    'post_type'      => 'page',
    'menu_order'     => 1,
    'comment_status' => 'closed',
    'ping_status'    => 'closed',
 ));  

// Find and delete the WP default 'Sample Page'
$defaultPage = get_page_by_title( 'Sample Page' );
wp_delete_post( $defaultPage->ID );

  restore_current_blog();
}

I’m adding this code in my child theme functions.php file. Any suggestion to fix this issue.