Show more information of ACF post object custom field

Content Views Pro helps you to show custom fields easily.
When showing a post object custom field of the Advanced Custom Fields plugin, Content Views Pro will show the title of the object by default.
To show more info of the object, 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):

add_filter( 'pt_cv_acf_post_object_html', 'cvp_theme_acf_post_object_html', 100, 2 );
/**
 * Content Views Pro - show more info of ACF post object
 * @param string $args The output of this ACF field (default output is the post title)
 * @param object $post The post object
 * @return string
 */
function cvp_theme_acf_post_object_html( $args, $post ) {
	global $pt_cv_id;
	if ( $pt_cv_id === 'VIEW_ID' ) {
		// For example: show thumbnail before title
		$args = get_the_post_thumbnail( $post->ID ) . $args;
	}

	return $args;
}

(replace VIEW_ID with ID of your View)

Best regards,

Scroll to Top