Hide Empty Labels in WP Maps Pro Info Windows

15000+ live websites are using this google maps wordpress plugin.

Hide Empty Labels for Extra Field Placeholders

Placeholders are used to display extra information about a location in the info window. WP MAPS PRO allows you to create unlimited extra fields and show them in both the map listing and marker info windows.

Sometimes, you may have multiple placeholders for different types of locations but use the same info window template for all of them. In such cases, if a placeholder has no value for a specific location, its label will still be displayed — leaving an empty label in the info window, which doesn’t look professional.

Problem:

Consider the following example where extra fields are displayed with labels:


Rating – {ratings}
Hours – {hours}
Website – {website}

In this setup, if a location does not have a rating, hours, or website, the label will still appear, but without any value, like this:

Empty Label Example

As you can see, the info window shows blank labels for fields without data.

Labels Without Data

Solution:

Wrap each label and its placeholder inside a <div> tag. This ensures that if the placeholder value is empty, the entire label and value block is hidden automatically.

Example:


<div><strong>Rating –</strong> {ratings}</div>
<div><strong>Hours –</strong> {hours}</div>
<div><strong>Website –</strong> {website}</div>

Hide Empty Labels in WP Maps Pro

By using this method, the label will only be displayed if its corresponding placeholder has a value. This keeps your info windows clean and professional.

Clean Info Window Example

Need help? Submit a support ticket and we’ll assist you!

Was this article helpful?
YesNo

Install Plugin Now!

WP MAPS PRO helps you create dynamic, customizable maps using Google Maps or Leaflet — no coding required. Includes free updates, premium support, and a 30-day money-back guarantee.