This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Isotopic link

#20656
Ernest MarcinkoErnest Marcinko
Keymaster

Hi!

Sure, the link is indeed controlled by the main script. However I do not recommend direct modifications to it, as it will reset every time you update the plugin. Instead, using a custom script within your child theme/theme functions file is a much viable option.
To prevent the redirection and to get the link URL, you need to attach an event to the result container, with event default prevention like so:

jQuery(function($) {
  $('.asp_r').off('click', '.asp_isotopic_item');
  $('.asp_r').on('click', '.asp_isotopic_item', function(e){
    e.preventDefault(); // Prevent redirection
    var url = $(this).find('a.asp_res_url').attr('href'); // Get the link URL
    // Do your code thing here, use the url variable for the link URL
  });
});

Now, to use it in the functions.php file in your theme directory, you can construct something like:

add_action('wp_footer', 'asp_footer_script_custom');
function asp_footer_script_custom() {
  ?>
  <script type="text/javascript">
  jQuery(function($) {
    $('.asp_r').off('click', '.asp_isotopic_item');
    $('.asp_r').on('click', '.asp_isotopic_item', function(e){
      e.preventDefault(); // Prevent redirection
      var url = $(this).find('a.asp_res_url').attr('href'); // Get the link URL
      // Do your code thing here, use the url variable for the link URL
    });
  });
  </script>
  <?php
}

The url variable holds the result URL, and the redirection is already prevented, so you can do whatever you want after that line.