WordPress rel=”nofollow ugc” attribute

Function Name: wp_rel_ugc()
Supported Version: WordPress 5.3+

What is rel UGC attribute?
UGC stands for User Generated Content, a rel attribute value recommended for links where the content was generated by user like comments or forum posts and Google made an announcement on Sept 10, 2019 for “ugc” link attribute value support.

In WordPress 5.3, a new function was introduced which help developers add both “nofollow” and “ugc” values to the rel attribute, see sample code below:

$url = '<a href="https://samplewebsite.com/comments/123">user forum comment</a>';
$ugc_url = wp_rel_ugc( $url );
echo $ugc_url;
// output: <a href="https://samplewebsite.com/comments/123" rel="nofollow ugc">user forum comment</a>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.