How to assign a Category to a Page, when both are created on theme initiation?

figured out how to accomplish my task :

// function to fetch tag ID from name
   function get_tag_ID($tag_name) 
   { $tag = get_term_by('name', $tag_name, 'post_tag'); if ($tag) { return $tag->term_id; } else { return NULL;}    }

// add categories & tag taxonomy to pages
   register_taxonomy_for_object_type( 'category', 'page' );
   register_taxonomy_for_object_type( 'post_tag', 'page' ); 

// let's create some stuff on init
    if (isset($_GET['activated']) && is_admin())       //check for init
    {  
        // create categories & tags
        if (file_exists (ABSPATH.'/wp-admin/includes/taxonomy.php'))
            {
                require_once (ABSPATH.'/wp-admin/includes/taxonomy.php'); 
                // categories
                $check = get_cat_ID('plants'); if(empty($check)) {wp_create_category('plants');}
                $check = get_cat_ID('animals'); if(empty($check)) {wp_create_category('animals');}

                //tags
                $check = get_tag_ID('tall'); if (empty($check)) {wp_create_tag('tall');}
                $check = get_tag_ID('short'); if (empty($check)) {wp_create_tag('short');}
            }

        // create pages
        $new_page_title="carrot";          // define PAGE TITLE
        $new_page_cat="plants";          // define PAGE CATEGORY
        $new_page_tag   = array('tall');     // define PAGE TAGS

        $page_check = get_page_by_title($new_page_title);
        if(!isset($page_check->ID))           // verify new page is unique
            {
            $new_page = array(
            'post_type'     => 'page',
            'post_title'    => $new_page_title,
            'post_content'  => 'more coming soon',
            'post_status'   => 'publish',
            'post_author'   => 1,
            'post_parent'   => '', );

            $post_cat = get_term_by('name', $new_page_cat, 'category');
            $post_cat = $post_cat->term_id;
            $new_page_cat = array($post_cat);

            $new_page_id = wp_insert_post($new_page);                   // create page
            wp_set_post_categories( $new_page_id,$new_page_cat, true ); // set category
            wp_set_post_tags( $new_page_id,$new_page_tag, true );       // set tags 
            }

    }

@Milo, thanks for your help 🙂

for anyone looking to do the same thing on the activation of their theme, this code works pretty well in all the testing i did : verifies that categories and tags to be created don’t already exist, verifies that the page to be created doesn’t already exist. page creation works and correctly links both category and tag to the created page. all the correct relationships show up when you look at your categories or tags index, so any searching by either should work correctly.

after theme activation you can use the get_tag_ID() function elsewhere in WP.

Pages will now be registered for both Category and Tag taxonomies, although coding or a plugin will be required to provide Admin metaboxes.

cheers.