Home > Helparticles > PRO-Plugin: API Zippopotamus

PRO-Plugin: API Zippopotamus

The API http://zippopotam.us/ gives Citynames and Coorindates to a Zipcode. The JCI-PRO-Plugin can use that for a “Zipcode to City-Search”:


Examples: Houston, US, TX | Munich, DE, Germany
This done this way:

1 .JCI-Template:

[jsoncontentimporterpro id=ID_OF_TEMPLATE httpstatuscodemustbe200=no]

2. twig-template:

  • url:
    http://api.zippopotam.us/{% if urlparam.co %}{{urlparam.co}}{% else %}US{% endif %}/{% if urlparam.zip %}{{urlparam.zip}}{% else %}80636{% endif %}
  • urlparam4twig: zip#co
  • twig-code (“/zippopotamus/” is the URL to the WordPress-Page with the Shortcode):
    {% if urlparam.co %}{% set coun = urlparam.co %}{% else %}{% set coun = "US" %}{% endif %}
    

    {% if places %} Found:
      {% for p in places %}
    1. {{ attribute(p, 'place name') }} ({{ attribute(p, 'state abbreviation') }})
    2. {% endfor %}
    {% else %} no City to this Zipcode {{urlparam.zip}} found {% endif %}
    Examples: Houston, US, TX | Munich, DE, Germany