I’m currently using the Paragraphs module. I have pretty much set up a simple bundle with a title, image and text area. I went into the basic page content type and added the paragraph field reference which worked fine. This had a limit of up to 6 paragraphs per basic page. They can add less than 6, just not any more than 6.

My question is, how do I count how many paragraphs have been entered on that particular basic page. I’m trying to count the amount of paragraphs added so each time it’s added it can dynamically modify the class containing the paragraph.

For example, using Foundation 5 I want to count how many entries have been made and if there is 3 paragraphs then I want the name of the class to be foo for example.

  • are you using Drupal 7 or 8 ? Commented Apr 5, 2017 at 9:09

2 Answers 2


if you have a multi-value paragraph field, then in your twig template file you can use


provided that you are using Drupal 8


If you're theming the paragraph field using a theme template or a preprocess function, an $id or $variables['id'] variable is available that has the count of the current paragraph item.

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.