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>
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>