Developers: How to set YARPP links to open in a New Window

If you’re comfortable with a bit of jQuery/JavaScript, for the thumbnail theme - add the following code to your theme template to open YARPP links in a new window:

jQuery version:

<script>
jQuery(document).ready(function($) {
 $(".yarpp-thumbnail").attr("target", "_blank");
});
</script>

Vanilla JavaScript version:

<script>
document.addEventListener('DOMContentLoaded', function() {
  var yarpp_els = document.querySelectorAll('.yarpp-thumbnail');
  for (var i=0; i < yarpp_els.length; i++) {
    yarpp_els[i].setAttribute('target', '_blank');
  }  
})
</script>
Was this article helpful?
0 out of 0 found this helpful