WP Team Ajax filter hash anchor

PHOTO EMBED

Wed Nov 12 2025 08:52:14 GMT+0000 (Coordinated Universal Time)

Saved by @Pulak

jQuery(document).ready(function ($) {

    $('.sptp-filter .button').on('click', function (e) {
        e.preventDefault();
        var slug = $(this).data('slug');
        if (slug) {
            window.location.hash = slug;
        } else {
            history.pushState("", document.title, window.location.pathname + window.location.search);
        }

        $('.sptp-filter .button').removeClass('is-checked');
        $(this).addClass('is-checked');
    });

    var hash = window.location.hash.substring(1); 
    if (hash) {
        var $targetButton = $('.sptp-filter .button[data-slug="' + hash + '"]');
        if ($targetButton.length) {
            $targetButton.trigger('click');
        }
    }

});
content_copyCOPY