Created
May 4, 2022 13:58
-
-
Save briansteeleca/261446093c62ce69d5140a496ef0a908 to your computer and use it in GitHub Desktop.
GridBuilderWP Map Popup with Featured Image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wp_grid_builder_map/marker_content', | |
function( $content, $marker ) { | |
ob_start(); | |
$url = wp_get_attachment_url( get_post_thumbnail_id() ); | |
$excerpt = get_the_excerpt(); | |
if ( $url ) { | |
echo '<div class="wpgb-map-marker-img">'; | |
echo '<div style="background-image:url(' . esc_url( $url ) . ');"></div>'; | |
echo '</div>'; | |
} | |
echo '<div class="wpgb-map-marker-body">'; | |
the_title('<h3 class="wpgb-map-marker-title"><a href="' . esc_url( get_the_permalink() ) . '">','</a></h3>'); | |
if ( $excerpt ) { | |
$excerpt = wp_trim_words( $excerpt, 26, '' ); | |
echo '<p class="wpgb-map-marker-content">' . wp_kses_post( $excerpt ) . '</p>'; | |
} | |
echo '</div>'; | |
return ob_get_clean(); | |
},10,2 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks so much, your code has helped me a lot,
best regards, margoux