<code>$node = new stdClass();
    $node->type = 'my_content_type';
    $node->format = 3;
    $node->status = 1;
    $node->uid = 2;
    $node->name = 'User_name';
    
    $node->title = "Test title";
    $node->body['und'][0]['value'] = "Body text";
    
    $node->field_taxonomy_field['und'][0]= array('tid' => 51); //51 is the term id
   
    node_object_prepare($node);
    
    $node->language = 'en';  
      
    $node->is_new = true;  
    $node = node_submit($node);
    $node_id =  node_save($node);</code>

Comments

comments

Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>