Page not visible in 'All pages' after being added through PHP

I'm adding some pages pragmatically as a subpage. This all works well on a test website in 1 locale. However, on the live website we have WPML with 2 locales. When adding them there, these pages DO NOT show up in the all pages list.

Also accessing their url give a 404. However, when you access the edit mode directly: https://xxxxxxx.nl/wp-admin/post.php?post=3280action=editlang=nl The page 'comes to life' (even without saving) and is visible as sub-page in the 'all pages' page.

Any idea how to get this working properly upon insertion in the db by PHP? Thanks!

function add_my_custom_page() {

    for( $i=1; $i = 3; $i++ ) {

        $my_posts = array(
          'post_title'    = wp_strip_all_tags( Video $i ),
          'post_name'     = v-$i,
          'post_type'     = page,
          'post_content'  = 'test',
          'post_status'   = publish,
          //'post_excerpt'  = v-$i,
          'post_parent'   = 3269,

          'post_author'   = get_current_user_id(),
          'page_template' = page-full-width.php,
        );

    

        // Insert the post into the database
        wp_insert_post( $my_posts, true );
        
    }

}

Topic plugin-wpml php pages Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.