[Resolved] How to add rel=“me” for link to a social link profile

Home Forums Support [Resolved] How to add rel=“me” for link to a social link profile

Home Forums Support How to add rel=“me” for link to a social link profile

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #2360154
    Justin

    I’m trying to figure out how to add a rel=“me” for a GB button that’s going to my social profile but the only option I see is rel=”nofollow”
    Add rel=”sponsored”

    #2360824
    Ying
    Staff
    Customer Support

    Hi Justin,

    The only way to do this with GB button block is to use a filter like this:

    add_filter( 'render_block', function( $content, $block ) {
    	if ( 
    		'generateblocks/button' === $block['blockName'] &&
    		(! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'button-me' ) !== false)
    	) {
    		return str_replace('nofollow', 'me', $content);
    	}
    
    	return $content;
    }, 10, 2 );	

    You need to add rel=”nofollow” to the button, add an additional CSS class to the button block, eg. button-me, then the filter above will replace the nofollow with me.

    https://wordpress.com/support/wordpress-editor/adding-additional-css-classes-to-blocks/

    #2360874
    Justin

    Where do I add the filter?

    #2360883
    Ying
    Staff
    Customer Support

    You can use a plugin called Code Snippet, and add the code via that plugin.

    Or if you are using a Child theme, it can be added to the functions.PHP file of the child theme 🙂

    #2360899
    Justin

    If I add this PHP code will it change or mess with my other GB buttons I have?

    #2360950
    Fernando
    Customer Support

    Hi Justin,

    The code provided by Ying works only for those GB Buttons you add the class button-me to.

    It won’t have any effect on other Buttons.

    #2360958
    Justin

    Perfect

    #2360992
    Fernando
    Customer Support

    You’re welcome Justin!

    #2484897
    Antulio

    Hello, when is GeneratePress will activate the rel=”me”? We should not add extra code nor adding additional plugins since they may be harm, or they slow web pages.

    #2485040
    Leo
    Staff
    Customer Support

    This isn’t related to the GeneratePress theme or GP Premium.

    The function is for GB 🙂

    Adding the code should have minimal to no impact on the performance of your site.

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