Skip to content

Instantly share code, notes, and snippets.

@jonathanfranks
Created April 20, 2015 23:45
Show Gist options
  • Save jonathanfranks/fd34ac9f21dae94eefbf to your computer and use it in GitHub Desktop.
Save jonathanfranks/fd34ac9f21dae94eefbf to your computer and use it in GitHub Desktop.
Publish all nodes of a type
public function iPublishAllNodes($content_type) {
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', $content_type);
$result = $query->execute();
if (isset($result['node'])) {
$nids = array_keys($result['node']);
$nodes = node_load_multiple($nids);
foreach ($nodes as $node) {
$node->status = 1;
node_save($node);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment