Skip to content

Instantly share code, notes, and snippets.

@rang501
Last active December 4, 2015 14:46
Show Gist options
  • Save rang501/6db8b6f59b40a8a535d5 to your computer and use it in GitHub Desktop.
Save rang501/6db8b6f59b40a8a535d5 to your computer and use it in GitHub Desktop.
Update node field programmatically
<?php
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'article');
$result = $query->execute();
if (isset($result['node'])) {
$nodes = entity_load('node', array_keys($result['node']));
foreach ($nodes as $node) {
$node->field_show_feedback[LANGUAGE_NONE][0]['value'] = 1;
$node->field_show_updated_date[LANGUAGE_NONE][0]['value'] = 1;
node_save($node);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment