Advertisement
jaideep06

New Sponsored for Nofollow

Jul 28th, 2021
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.55 KB | None | 0 0
  1. add_action( 'wp_head', function () { ?>
  2. <script>
  3.     /* write your JavaScript code here */
  4.     //<![CDATA
  5.     jQuery(document).ready(function($) {
  6.         $('a').each(function() {
  7.             var a = new RegExp('/' + window.location.host + '/');
  8.             if (!a.test(this.href)) {
  9.                 if ($(this).attr("rel", "nofollow")) {
  10.                     $(this).attr("rel","sponsored");
  11.                 }
  12.                
  13.                 //$(this).click(function(event) {
  14.                     //event.preventDefault();
  15.                     //event.stopPropagation();
  16.                     //window.open(this.href, '_blank');
  17.                 //});
  18.             }
  19.         });
  20.     });
  21.     //]]>
  22. </script>
  23. <?php } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement