Use custom title for posts in View

Content Views helps you to show any information of WordPress posts easily: title, content, thumbnail…
About title, Content Views will display the post’s title. If you want to show a custom title for the post in View (and keep the WordPress post’s title unchanged), please follow 2 simple steps:

  • Add new custom field with name is cvp_custom_title and value is the custom title you want to show (click to read about how to add new custom field)
  • Add this code to file functions.php of your active theme:
    // Content Views Pro - Replace title by a custom field
    add_filter( 'pt_cv_field_title_result', 'cvp_theme_replace_title_by_ctf', 100, 3 );
    function cvp_theme_replace_title_by_ctf( $title, $fargs, $post ) {
    	$meta = get_post_meta( $post->ID );
    
    	if ( !empty( $meta[ 'cvp_custom_title' ][ 0 ] ) ) {
    		$title = $meta[ 'cvp_custom_title' ][ 0 ];
    	}
    
    	return $title;
    }
    

Notice: If you want to use another custom field to replace post title, please replace cvp_custom_title in above code with name of your field.

Best regards,