Archived topic
How to add rel=“me” for link to a social link profile
9 replies · Started by Justin on October 1, 2022
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"
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/
Where do I add the filter?
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 :)
If I add this PHP code will it change or mess with my other GB buttons I have?
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.
Perfect
You're welcome Justin!
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.
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.