Show the structured data of the WordPress posts list by Content Views

Structured data is a standardized format for providing information about a page and classifying the page content; for example, on a recipe page, what are the ingredients, the cooking time and temperature, the calories, and so on.
You can read more about it here.

This document includes solution to display structured data of the WordPress posts list by Content Views (and Content Views Pro) in JSON-LD format.
This data has a short description of each item in the list, and each description points to a separate details page that is focused entirely on one item, for example:

structured-data

To generate that summary structured data, please add this code to file functions.php in the theme’s folder:

// Content Views - show structured data of the posts list
add_action( 'wp_footer', 'cvp_theme_show_structured_data' );
function cvp_theme_show_structured_data() {
	if ( !empty( $GLOBALS[ 'cv_posts' ] ) ) {
		$list = array();
		foreach ( $GLOBALS[ 'cv_posts' ] as $idx => $post ) {
			$list[] = array(
				"@type"		 => "ListItem",
				"position"	 => $idx + 1,
				"url"		 => get_permalink( $post )
			);
		}

		echo '<script type="application/ld+json">{"@context":"http://schema.org", "@type":"ItemList", "itemListElement":' . json_encode( $list, JSON_UNESCAPED_SLASHES ) . '}</script>';
	}
}

Best regards,