Replace the default excerpt-based infobox body with custom HTML built from meta fields, taxonomies, or shortcodes.
/**
* Custom Progress Map infobox description.
*
* @param string $default_content Default content.
* @param int $post_id Location post ID.
*/
function my_custom_infobox_description( $default_content, $post_id ) {
$name = get_post_meta( $post_id, 'YOUR_NAME_FIELD', true );
$address = get_post_meta( $post_id, 'YOUR_ADDRESS_FIELD', true );
$website = get_post_meta( $post_id, 'YOUR_WEBSITE_FIELD', true );
$custom_content = '<strong>Name: </strong>' . esc_html( $name ) . '<br />';
$custom_content .= '<strong>Address: </strong>' . esc_html( $address ) . '<br />';
if ( $website ) {
$custom_content .= '<strong>Website: </strong><a href="' . esc_url( $website ) . '">Visit</a>';
}
return $custom_content;
}
add_filter( 'cspm_custom_infobox_description', 'my_custom_infobox_description', 10, 2 );
Related filters
Legacy docs also cover title and class customizations. Common patterns:
- Infobox title — look for title-related
cspm_*filters in Ultimate / return a custom string from post data. - Read more link — append HTML to your custom description.
- CSS classes — add wrapper classes in your returned HTML for theme styling.
Example “Read more” append:
$custom_content .= '<p><a class="cspm-read-more" href="' . esc_url( get_permalink( $post_id ) ) . '">Read more</a></p>';
Tips
- Escape output (
esc_html,esc_url) — infobox HTML is front-end visible. - Keep content short for mobile.
- Admin field builders (custom title/content from fields) may be enough without PHP — see Infoboxes & carousel.
