Set custom text for an URL custom field

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

Content Views Pro will convert that URL string to a HTML link (anchor tag):

How to use your own 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="">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 ( $key === 'CUSTOM_FIELD_KEY_HERE' ) {
        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_KEY_HERE with name of your custom field)

Best regards,