Skip to content

Instantly share code, notes, and snippets.

@yaserahmady
Last active October 12, 2022 14:56
Show Gist options
  • Save yaserahmady/c4db16f65ff7c94789c96570b15a3f45 to your computer and use it in GitHub Desktop.
Save yaserahmady/c4db16f65ff7c94789c96570b15a3f45 to your computer and use it in GitHub Desktop.
Elementor Portfolio Widget URL hash filter

Add this JS script in Elementor → Custom Code at the end of the body.

(function ($) {
  $(window).load(function () {
    if (window.location.hash) {
      console.log("We have some hash!");
      var hash = window.location.hash.replace("#", "");
      console.log("Filtering...");
      $(`li.elementor-portfolio__filter[data-filter=${hash}]`).trigger(
        "click"
      );
    }
  });
})(jQuery);

You can find the direct links to each category by putting this snippet in the Console:

$$(".elementor-portfolio__filter").map(f => {
    console.log(`${f.innerText} = #${f.dataset.filter}`);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment