Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #649293

    So that I can comply with Google’s heavy-handed guidelines, I need to be able to selectively add the rel=”nofollow” attribute to all my Promo Boxes and Buttons.

    Below, I’ve included links to example pages where I use the Promo Box and Buttons quite judiciously. They all need a rel=”nofollow” link added:

    Promo Boxes: http://www.guitaranswerguy.com/11-jamplay-walkthrough/
    Buttons: http://www.guitaranswerguy.com/guitar-resources/

    I’m comfortable writing and modifying a little code, if necessary.

    Thanks!

    p.s. – I tried this solution: https://kriesi.at/support/topic/add-relnofollow-on-button-links/ but it puts the “nofollow” on the outer <div> tag, whereas I need it within the actual HREF tag.

    #650559

    Hey Bobby,

    Thank you for using Enfold.

    Please replace the custom script with the following:

    // custom script
    add_action('wp_footer', 'ava_custom_script');
    function ava_custom_script(){
    ?>
    <script>
    (function($) {
    	function a() {
    		$('.av_promobox').each(function() {
    			$(this).find('.avia-button-wrap a').attr('rel', 'nofollow');
    		});
    	}
    
    	a();
    })(jQuery);
    </script>
    <?php
    }

    Best regards,
    Ismael

    #651129

    Unfortunately, this isn’t doing what I need (unless I implemented it incorrectly). It simply adds another CSS class called “nofollow” or “rel-nofollow” within the DIV element that is around the HREF. You can see this here:

    http://www.guitaranswerguy.com/guitar-resources/

    I applied your suggestion to the very 1st button on the page (“Buy it on Amazon.com” button under “Humitar Acoustic Guitar Humidifier”). If you view the source code, you’ll see what I mean. It’s simply adding another CSS class to the DIV, not adding rel=”nofollow” to my anchor link:

    View Source

    Instead, what I need is something like this:

    <a href="http://someurl.com" rel="nofollow" target="_blank">Buy it on Amazon.com</a>

    Note that the rel=”nofollow” is inside the A tag itself.

    #652136

    Hi,

    Please add following code to Functions.php file of your child theme in Appearance > Editor

    function custom_class_rel(){
    ?>
     <script>
    jQuery(window).load(function(){
    jQuery('.rel-nofollow a').attr('rel','nofollow');
    });
     </script>
    <?php
    }
    add_action('wp_footer', 'custom_class_rel');

    Best regards,
    Yigit

    • This reply was modified 8 years, 5 months ago by Yigit.
    #652272

    I’ll give it a try. Should this code REPLACE the code I added before? Or, this this be added IN ADDITION to the previous code?

    Thanks,

    Bobby

    #653131

    Hi,

    This code would work as long as you keep the custom CSS class on your element.
    P.S.: I just noticed that i made a typo in the code and corrected it.

    Best regards,
    Yigit

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.