Hello,
Please use below filter code to add line breaks within the address:
add_filter( 'rank_math/shortcode/contact/address_parts_format', function( $parts ){
return $parts . '<br />';
});
Also, if it’s possible, I’d also like to remove the map and create another version of the shortcode to display *only* the map. Is this possible?
To remove the map from the existing shortcode and display it in a new shortcode, please add below code in functions.php file:
add_filter( 'shortcode_atts_contact-info', function( $out, $pairs, $atts, $shortcode ){
$out['show'] = 'address, hours, phone, social';
return $out;
}, 10, 4 );
add_shortcode( 'rank_math_contact_info_map', function(){
$address = RankMath\Helper::get_settings( 'titles.local_address' );
if ( false === $address ) {
return;
}
/**
* Filter address for Google Map in contact shortcode.
*
* @param string $address
*/
$address = apply_filters( 'rank_math/shortcode/contact/map_address', implode( ' ', $address ) );
$address = apply_filters( 'rank_math/shortcode/contact/map_iframe_src', '//maps.google.com/maps?q=' . urlencode( $address ) . '&z=15&output=embed&key=' . urlencode( RankMath\Helper::get_settings( 'titles.maps_api_key' ) ) );
return '<div class="rank-math-contact-section rank-math-contact-map"><iframe src="' . esc_url( $address ) . '"></iframe></div>';
});
After adding this code, you can use [rank_math_contact_info_map]
shortcode to show the map.
I hope that helps. If there is anything else, please let us know.
Thank you.