New home › Forums › Pro Add-on › Display custom field name in Modern marker list
Tagged: custom fields, marker list
- This topic has 5 replies, 2 voices, and was last updated 1 year, 2 months ago by Matthew.
-
AuthorPosts
-
January 14, 2022 at 3:50 pm #71951Gabriel_CCParticipant
Hello,
as the title says, I would like to display the custom field name before the value in the modern marker list, not just the value. For example:Parking: Yes.
Thank you for your time!
Gabriel
January 17, 2022 at 9:14 am #71972MatthewModeratorHi Gabriel,
Thank you for getting in touch with us, we do appreciate your time.
This is indeed possible using some custom JS code which I am happy to assist you with.
Thus please may I kindly ask if you may provide me with the link to your map page so that I may take a closer look and thus write the necessary custom code?
I look forward to hearing back from you.
Kindest Regards,
MatthewJanuary 19, 2022 at 10:27 am #72008Gabriel_CCParticipantThis reply has been marked as private.January 20, 2022 at 10:27 am #72015MatthewModeratorHi Gabriel,
Thank you for getting back to me and for your time on this, I really appreciate it!
Thank you for the link, I have thus written the respective custom JS code needed to display the custom field labels for the modern marker listing style:
jQuery(function($){ WPGMZA.PopoutPanel.prototype.open = function() { $(this.element).addClass("wpgmza-open"); var popoutPanel = $('.wpgmza-popout-panel.wpgmza-modern-marker-listing-marker-view'); setTimeout(function(){ $('.wpgmza-popout-panel.wpgmza-modern-marker-listing-marker-view p').each(function(){ var pTag = $(this); console.log(pTag.attr('data-custom-field-name')); if( pTag.attr('data-custom-field-id') == undefined ){ // Dont do anything } else { var custom_field_val = pTag.html(); console.log(custom_field_val); var custom_field_label = pTag.attr('data-custom-field-name'); var reformatted = '<strong>' + custom_field_label + ': </strong>' + custom_field_val; pTag.html(reformatted); } }); }, 100); } })
Please may you copy, paste and save the above JS code into the “Custom JS” setting block (Maps -> Settings -> Advanced Settings)?
Once this has been done, please may you clear your browser cache and confirm if this helps?
I look forward to hearing back from you.
Kindest Regards,
MatthewJanuary 20, 2022 at 11:37 am #72017Gabriel_CCParticipantHi Matthew, it worked perfectly, thank you very much!
Gabriel
January 20, 2022 at 12:08 pm #72018MatthewModeratorHi Gabriel,
Thank you for getting back to me and most valued time, I tremendously appreciate it!
I am most happy to hear that, and it was my great pleasure assisting you with this.
Please may you kindly consider reviewing our plugin at https://wordpress.org/support/plugin/wp-google-maps/reviews/#new-post?
It would really mean the world to me! And if possible, please could I kindly ask you to mention both your name and mine in the review for administrative purposes as this would be a tremendous help?
Should you ever require any further assistance, I am more than happy to help.
Have a fantastic day and week further!
Kindest Regards,
Matthew -
AuthorPosts
- You must be logged in to reply to this topic.