Set custom text for an URL custom field

If you are showing a custom field which has an URL string as value, for example:

http://google.com

Content Views Pro will convert that URL string to a HTML link (anchor tag):
http://google.com

How to use a custom text for the link?
There are 2 possible ways:

1. Manually replace the URL string in the value of custom field by an anchor tag:

<a target="_blank" href="http://google.com">YOUR TEXT HERE</a>

2. Dynamically replace the URL string by an anchor tag using PHP code.
Please add this code to file functions.php in the theme’s folder (or install this plugin Code Snippets then add this code to the “Code” textarea):

// Content Views Pro - disable auto convert url to link
add_filter( 'pt_cv_wrap_ctf_value', '__return_false' );

// Content Views Pro - Set custom text for an URL custom field
add_filter( 'pt_cv_ctf_value', 'cvp_theme_ctf_url_custom_text', 100, 3 );
function cvp_theme_ctf_url_custom_text( $url, $key, $post ) {
	if ( !empty( $url ) && in_array( $key, array( 'CUSTOM_FIELD_1', 'CUSTOM_FIELD_2', 'CUSTOM_FIELD_3', 'CUSTOM_FIELD_4' ) ) ) {
		if ( !filter_var( $url, FILTER_VALIDATE_URL ) ) {
			$matches = array();
			preg_match( '/href="([^"]+)"/', $url, $matches );
			$url	 = !empty( $matches[ 1 ] ) ? $matches[ 1 ] : $url;
		}

		$url = '<a href="' . esc_url( $url ) . '">Custom Text</a>';
	}

	return $url;
}

(replace CUSTOM_FIELD_1, CUSTOM_FIELD_2, CUSTOM_FIELD_3, CUSTOM_FIELD_4 with your custom field keys. If you have only one custom field, just replace CUSTOM_FIELD_1 with your custom field key.)

Best regards,