Display custom field name in infowindow

New home Forums Pro Add-on General queries Display custom field name in infowindow

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #72177
    marcelo
    Participant

    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 Paulo

    If you could help me with some custom JavaScript to achieve the desired result. I would be very grateful

    Marcelo

    #72186
    Steven
    Moderator

    Hi @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 Beer

    #72209
    marcelo
    Participant

    Hi Steven
    Thank you very much, it worked!

    #72212
    Steven
    Moderator

    Hi @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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.