I wanted to insert a related-articles block after the n-th content element using stash. But it seems Content Elements doesn't provide a {count} variable in the elements loop.

1 Answer 1


I've added a {ce_counter} variable to the elements loop.

Open the ft.content_elements.php file and navigate to the replace_tag function.

Insert $i_counter = 0; just before the foreach $data loop.

In the loop, look for the // Counter section and add:

$tagdata_parsed = str_replace('{ce_counter}', $i_counter, $tagdata_parsed);

In the loop, look for the // Parse varibles in conditions sections and add 'ce_counter' => (int) $i_counter as an extra array item.

Now you can use {ce_counter} as a variable in the loop.

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.