Hello, I re-open this thread because I see tag order don't work for me.
I've got a lot of tags, and when I tried to re-order them (having numbers before words) it works only on certain number values, and not with others, even if in the tags page numbers appears as first.
Here a pic of how I sorted them, but still in this page they appears sometimes in the middle of 3 tags line https://landcho.eu/all-projects/
I used this code in custom head content:
<script defer>
if (window.location.pathname.includes("all-projects")) {
document.addEventListener("DOMContentLoaded", function () {
const thumbnails = document.querySelectorAll(".below-image");
thumbnails.forEach(function (thumb) {
const tags = thumb.querySelectorAll(".thumbnail-tags span");
if (!tags.length) return;
const tagArray = Array.from(tags);
// Ordina: numerici prima, poi alfabetici
tagArray.sort((a, b) => {
const aIsNumber = /^\d/.test(a.textContent.trim());
const bIsNumber = /^\d/.test(b.textContent.trim());
if (aIsNumber && !bIsNumber) return -1;
if (!aIsNumber && bIsNumber) return 1;
return a.textContent.localeCompare(b.textContent);
});
const tagContainer = thumb.querySelector(".thumbnail-tags");
if (tagContainer) {
tagContainer.innerHTML = "";
tagArray.forEach(tag => tagContainer.appendChild(tag));
}
});
});
}
</script>
but it works only when I refresh the page, not when I arrive there directly.
Any suggestions for how to fix it? @arminunruh maybe?
Thanks!
Roberta