Automatically counts CMS work items
Copy and paste this code snippet into the settings of the Works page, before <body> tag.
<script>
document.addEventListener("DOMContentLoaded", () => {
const items = document.querySelectorAll("[dynamic-count='item']");
const counter = document.querySelector("[dynamic-count='counter']");
const totalCount = items.length;
items.forEach((item, index) => {
item.setAttribute("dynamic-count", `item-${(index + 1).toString().padStart(2, '0')}`);
});
if (counter) {
counter.textContent = `${totalCount.toString().padStart(2, '0')}`;
}
});
</script>