Title: Using Subdivisions in Shortcode
Last modified: May 1, 2018

---

# Using Subdivisions in Shortcode

 *  Resolved [heartwired](https://wordpress.org/support/users/heartwired/)
 * (@heartwired)
 * [8 years ago](https://wordpress.org/support/topic/using-subdivisions-in-shortcode/)
 * Hey there!
    Love what you’ve done with the plugin. Unfortunately, I’m having 
   an issue with getting the isoCode of Subdivisions using a shortcode.
 * In your example, you show how to get the isoCode of a country:
    **PHP –** $userInfo-
   >country->isoCode **Shortcode –** [geoip_detect2 property=”country.isoCode”]
 * I’m trying to get the isoCode of the subdivision, but the Subdivisions object
   structure differs from all the others in the MaxMind GeoIP2 code. This is how
   the object starts:
 *     ```
       [subdivisions:protected] => Array
           (
               [0] => GeoIp2\Record\Subdivision Object
                   (
                       [validAttributes:protected] => Array
                           (
                               [0] => confidence
                               [1] => geonameId
                               [2] => isoCode
                               [3] => names
                           )
       ```
   
 * The other objects, such as country and city do not have the **[0] => GeoIp2\Record\
   Subdivision Object** line. This is an issue, because I’m not sure how to access
   the isoCode for this in a shortcode.
 * I’m able to use php to print out the isoCode using **$userInfo->subdivisions[
   0]->isoCode;**
    My guess for the shortcode would be something like **[geoip_detect2
   property=”subdivisions.0.isoCode”]** but that doesn’t work.
 * Do you know of a way to access this via a shortcode?
 * Hopefully that makes sense, and there’s a simple way to create a shortcode from
   this!
    Thanks for your help!

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Benjamin Pick](https://wordpress.org/support/users/benjamin4/)
 * (@benjamin4)
 * [8 years ago](https://wordpress.org/support/topic/using-subdivisions-in-shortcode/#post-10237905)
 * Oh I think this case is not covered yet. Can you tell me an example IP for this?
 *  Thread Starter [heartwired](https://wordpress.org/support/users/heartwired/)
 * (@heartwired)
 * [8 years ago](https://wordpress.org/support/topic/using-subdivisions-in-shortcode/#post-10238729)
 * Do you mean an example IP address so you can test it? I’m not sure I understand.
   
   Thanks for your quick reply.
 *  [Benjamin Pick](https://wordpress.org/support/users/benjamin4/)
 * (@benjamin4)
 * [8 years ago](https://wordpress.org/support/topic/using-subdivisions-in-shortcode/#post-10238855)
 * Yes – because in my country (Germany) there is only one subdivision or sometimes
   none at all.
 *  Thread Starter [heartwired](https://wordpress.org/support/users/heartwired/)
 * (@heartwired)
 * [8 years ago](https://wordpress.org/support/topic/using-subdivisions-in-shortcode/#post-10238867)
 * Here’s an IP from California: 66.249.73.192
    This would return ‘CA’ for the line:**
   $userInfo->subdivisions[0]->isoCode;**
 * Does that help?
 *  [Benjamin Pick](https://wordpress.org/support/users/benjamin4/)
 * (@benjamin4)
 * [8 years ago](https://wordpress.org/support/topic/using-subdivisions-in-shortcode/#post-10242269)
 * For this, you could use this shortcode (as shown on the lookup page):
    `[geoip_detect2
   property="mostSpecificSubdivision.isoCode"]`. Is this working for you?
 *  [Benjamin Pick](https://wordpress.org/support/users/benjamin4/)
 * (@benjamin4)
 * [8 years ago](https://wordpress.org/support/topic/using-subdivisions-in-shortcode/#post-10242397)
 * Alternatively, you can use the current beta where the new shortcode syntax works.
   
   [https://github.com/yellowtree/wp-geoip-detect/archive/master.zip](https://github.com/yellowtree/wp-geoip-detect/archive/master.zip)
 * `[geoip_detect2 property=”subdivisions.0.isoCode”]`
 *  Thread Starter [heartwired](https://wordpress.org/support/users/heartwired/)
 * (@heartwired)
 * [8 years ago](https://wordpress.org/support/topic/using-subdivisions-in-shortcode/#post-10243295)
 * Awesome!
    The mostSpecificSubdivision shortcode did work. Thank you so much for
   your quick work on this. It blows my mind.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Using Subdivisions in Shortcode’ is closed to new replies.

 * ![](https://ps.w.org/geoip-detect/assets/icon-256x256.jpg?rev=978998)
 * [Geolocation IP Detection](https://wordpress.org/plugins/geoip-detect/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/geoip-detect/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/geoip-detect/)
 * [Active Topics](https://wordpress.org/support/plugin/geoip-detect/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/geoip-detect/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/geoip-detect/reviews/)

## Tags

 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 7 replies
 * 2 participants
 * Last reply from: [heartwired](https://wordpress.org/support/users/heartwired/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/using-subdivisions-in-shortcode/#post-10243295)
 * Status: resolved