Customize carousel item content


Programmatically change carousel item HTML when admin “custom content from fields” is not enough.

/**
 * Custom Progress Map carousel item content.
 *
 * @param string $default_content Default item content.
 * @param int    $post_id         Location post ID.
 */
function my_custom_carousel_item_content( $default_content, $post_id ) {

	$price = get_post_meta( $post_id, 'price', true );
	$city  = get_post_meta( $post_id, 'city', true );

	$html  = '<div class="my-carousel-meta">';
	$html .= '<span class="city">' . esc_html( $city ) . '</span>';
	if ( $price ) {
		$html .= '<span class="price">' . esc_html( $price ) . '</span>';
	}
	$html .= '</div>';

	// Keep part of the default excerpt if useful:
	// $html .= $default_content;

	return $html;
}
add_filter( 'cspm_custom_item_description', 'my_custom_carousel_item_content', 10, 2 );

Custom titles use cspm_custom_item_title the same way.

List & Filter

When List & Filter replaces the carousel, customize list rows instead — see List & Filter recipes.

Tips

  • Prefer consistent structure so CSS can style every item.
  • Avoid heavy shortcodes inside every carousel card on large maps.
Top