Get all instances of a content type Is there a function in Drupal 7 to pull all instances of a specific content type to store in an array? Ex: Say I have a content type called "us_states" and I want to pull each instance of that type (with it's saved data so the title, description, and the custom content I created) and store them into an array. How should I go about doing that?
Two options: node_load_multiple() function (deprecated) or EntityFieldQuery Class (preferred).


Example node_load_multiple():

$nodes = node_load_multiple(array(), array('type' =&gt; 'us_states'));



  The second argument ($conditions) is marked as deprecated; and you can see that in the Drupal 8 documentation for the same function, it has been removed. I only included this example because I'm sure someone else would have pointed it out had I not and the fact that you specifically asked for a function.

Example EntityFieldQuery (Use this):

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')
  -&gt;entityCondition('bundle', 'us_states');
$nodes = $query-&gt;execute();



In both examples, $nodes will be an array containing all nodes of the content type 'us_states'. (Note that the nodes within the array will be objects per usual.)

If you really need to use a function (that won't be deprecated in Drupal 8), you can pass an array of Node IDs as the first param to node_load_multiple() that contains the Node IDs of all of the 'us_states'.