Use custom Title for posts

Content Views helps you to show any information of WordPress posts easily: title, content, thumbnail, author, category… By default, Content Views will display the post’s title.

To show a custom title for posts in our shortcode/block (and keep the original post’s title unchanged), please do as follow:

If you are using Content Views Pro version <= 5.7.1, it requires another step: please add this code to file functions.php of your active theme:

// Content Views Pro - Show custom title
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 );

	$custom_field = 'cvp_custom_title';
	if ( !empty( $meta[ $custom_field ][ 0 ] ) ) {
		$title = $meta[ $custom_field ][ 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,

Scroll to Top