Skip to content

Instantly share code, notes, and snippets.

@briansteeleca
Created May 4, 2022 13:58
Show Gist options
  • Save briansteeleca/261446093c62ce69d5140a496ef0a908 to your computer and use it in GitHub Desktop.
Save briansteeleca/261446093c62ce69d5140a496ef0a908 to your computer and use it in GitHub Desktop.
GridBuilderWP Map Popup with Featured Image
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
);
@briansteeleca
Copy link
Author

Code snippet posted on Facebook by Robert Szlaga – he said he got it from GridBuilderWP support.

For use with Oxygen, paste this in a snippet using the Code Snippets plugin.

@margoux
Copy link

margoux commented Feb 29, 2024

thanks so much, your code has helped me a lot,
best regards, margoux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment