Display Number Of CMS Items
Utility
CMS
JS
- Give the section a class of your-section
- Give the cms items a class of your-cms-items
- Give the text element that should display the number of cms items a class of your-number-text
<script>
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".your-section").forEach(component => {
const itemTotal = component.querySelectorAll(".your-cms-items").length;
component.querySelectorAll(".your-number-text").forEach(el => el.textContent = itemTotal);
});
});
</script>Preview Links
Custom JS
Enable custom code in preview or view on published site.
Enable custom code?
Last Updated: Dec 3, 2025
- Give the section a class of your-section
- Give the cms items a class of your-cms-items
- Give the text element that should display the number of cms items a class of your-number-text
<script>
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".your-section").forEach(component => {
const itemTotal = component.querySelectorAll(".your-cms-items").length;
component.querySelectorAll(".your-number-text").forEach(el => el.textContent = itemTotal);
});
});
</script>