I have a custom template for a node, and a field which has the possibility of having multiple pieces of data. In this case:

  • There is an Author node
  • There are Publication nodes
  • Publications are being Entity Referenced on the Author node

The custom template then prints the publications to the node

<?php print render($content['field_publications']); ?>

I know that adding ['1'] displays the first publication if multiple publications are attached to the same author, however, how would I display the top 5 publications, if say, there was 10 publications by the same author?

1 Answer 1


Slice the array?

foreach(array_slice($content['field_publications'], 0, 5) as $field_publication):

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.