A programmer friend helped me by adjusting the above code to get it to work on my site. I'm assuming these adjustments are needed to get it working in SS 7.1.
The code below will add an underline to the active tagcloud anchor tag
<!--- Add style="text-decoration: underline;" for currently selected tag filter --------------------------><script>(function(){const tagCloud = document.querySelector(".sqs-tagcloud");if(tagCloud){const currentPath = window.location.pathname + window.location.search;const selectTag = tagCloud.querySelector(`li a[href*='${currentPath}']`);if(selectTag){
selectTag.style.textDecoration ="underline";}}})()</script>
Instead of adding a style, I want to add a class. With my limited JS knowledge I was able to accomplish it by modifying the above script like this
<!--- Add class="tag-active" for currently selected tag filter --------------------------><script>(function(){const tagCloud = document.querySelector(".sqs-tagcloud");if(tagCloud){const currentPath = window.location.pathname + window.location.search;const selectTag = tagCloud.querySelector(`li a[href*='${currentPath}']`);if(selectTag){
selectTag.classList.add("tag-active");}}})()</script>
Is this still the code you used for your site? It looks great! I'm trying to do something similar but the code isn't working.
Blog taglcoud - way to indicate which tag user is currently viewing?
in Customize with code
Posted
Is this still the code you used for your site? It looks great! I'm trying to do something similar but the code isn't working.