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>
We’ve tried our best to explain everything thoroughly, even though there’s so much information out there. If you found our writing helpful, we’d really appreciate it if you could buy us a coffee as a token of support.