Skip Navigation

[Resolved] Can I display just the state and country name from an address field?

This support ticket is created 6 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#706357

I would like to display content specific to a user's home state and country, and I would prefer to have them enter their home address using the address field type so I can take advantage of map options. However, to pull up the state-specific information I need to filter a view based on the user's state. Is there a way to parse out just the state name and country name (separately) and send it to the view that would avoid me having to create redundant fields in the user field group for "state" and "country"? Thanks.

- Aaron

#710746

Hi, when an address is geocoded we store the full address as a string, so there's no easy way to break apart each individual component. It might be possible to do this with custom code, but that falls outside the scope of the support we provide here in the forums. If you'd like, you can submit a feature request describing what you would like to achieve, and our developers will evaluate it.

#711330

Hi Christian,

I feared that might be the answer. Yes, if you could add this as a feature request it would be appreciated. I would think this would be a universally beneficial feature in that users could build their WordPress sites to use the address field and be able to pull all geographic information just from that one entry. Thanks for the consideration!

- Aaron

#711792

Okay in the meantime another ticket here on the forum provides an example of one way you could use custom code to accomplish this in wp-admin:
https://toolset.com/forums/topic/separating-content-from-the-address-field/