I want to query last 5 nodes of multiple content types, say, typeA
, typeB
, typeC
, typeD
.
It was originally only one content type, and I did it using EntityFieldQuery:
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'typeA')
->propertyCondition('status', 1)
->propertyOrderBy('created', 'DESC')
->range(0, 5);
$result = $query->execute();
But now I need to include 3 other content types to the list.
Is there any way to expend this query to include the last 5 nodes of the other 3 content types as well. So that the result will have 5 last nodes from all 4 content types, altogether 20 nodes.
Or should I do it with 4 individual queries?
union
once if you want to do it with the single query.