New home › Forums › Pro Add-on › General queries › Display custom field name in infowindow
Tagged: infoWindow
- This topic has 3 replies, 2 voices, and was last updated 1 year, 7 months ago by Steven.
-
AuthorPosts
-
February 4, 2022 at 7:09 pm #72177marceloParticipant
Hi,
I would like to display the custom field name before the value in the Default InfoWindow, not just the value. For example:Parking: Yes
City: Sao PauloIf you could help me with some custom JavaScript to achieve the desired result. I would be very grateful
Marcelo
February 7, 2022 at 9:19 am #72186StevenModeratorHi @Marcelo,
Thank you so much for getting in touch, we really appreciate your time.
Could I kindly ask you to navigate to -> Maps -> Settings -> Advanced Settings -> Please copy the below custom Script and paste this in the custom JS field:
jQuery(document.body).on("infowindowopen.wpgmza", function(e){ console.log('opened'); jQuery(".wpgmza-infowindow p").each(function(){ var customFieldTitle = jQuery(this).data("custom-field-name"); console.log(customFieldTitle); if(customFieldTitle){ jQuery(this).html("<strong>" + customFieldTitle + "</strong>" + ":" + jQuery(this).text()); } }); });
Once complete, please save the settings and confirm if this helps?
Kindest Regards,
Steven De BeerFebruary 7, 2022 at 1:20 pm #72209marceloParticipantHi Steven
Thank you very much, it worked!February 7, 2022 at 3:13 pm #72212StevenModeratorHi @marcelo,
Thank you so much for getting back to me.
I am glad to hear this has helped.
Do let me know if there is anything more I can help with as I am always eager to assist. 🙂
If you ever have two minutes spare, please consider reviewing the plugin on Twitter @WPGMaps or if you don’t use Twitter on https://wordpress.org/support/plugin/wp-google-maps/reviews/#new-post it would mean the world to me! (If possible, could I ask you to mention both your name and mine in the review for administrative purposes, this would be a tremendous help!)
Do have a great week ahead!
Kindest Regards,
Steven De Beer -
AuthorPosts
- You must be logged in to reply to this topic.