wp_rel_ugc() WordPress Function

The wp_rel_ugc() function allows you to display related posts from users who have commented on the same post as the current user. This is a great way to encourage user engagement and get more comments on your site.

wp_rel_ugc( string $text ) #

Adds rel="nofollow ugc" string to all HTML A elements in content.


Parameters

$text

(string)(Required)Content that may contain HTML A elements.


Top ↑

Return

(string) Converted content.


Top ↑

Source

File: wp-includes/formatting.php

function wp_rel_ugc( $text ) {
	// This is a pre-save filter, so text is already escaped.
	$text = stripslashes( $text );
	$text = preg_replace_callback(
		'|<a (.+?)>|i',
		static function( $matches ) {
			return wp_rel_callback( $matches, 'nofollow ugc' );
		},
		$text
	);
	return wp_slash( $text );
}


Top ↑

Changelog

Changelog
VersionDescription
5.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More