• Resolved gafco

    (@gafco)


    Hi,
    Im trying to use a subloop-array for data but having trouble. This is the JCON data:

    "current": {
            "last_updated_epoch": 1623959100,
            "last_updated": "2021-06-17 15:45",
            "temp_c": 27.8,
            "temp_f": 82.0,
            "is_day": 1,
            "condition": {
                "text": "Partly cloudy",
                "icon": "//weather/64x64/day/116.png",
                "code": 1003
    }

    Im using this subloop:
    {subloop-array:condition:-1}
    <p>Condition: {condition.text}
    {/subloop-array:condition}

    The Condition is blank. Any ideas?

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author berkux

    (@berkux)

    Hi,

    you might try this:

    {subloop:current:-1}
    last_updated_epoch: {last_updated_epoch}<br>
    {subloop:current.condition:-1}
    <p>Condition: {current.condition.text}
    {/subloop:current.condition}
    current
    {/subloop:current}
    

    Bernhard

    Thread Starter gafco

    (@gafco)

    No luck. This is what it returned:
    last_updated_epoch: 1624367700

    Condition:

    Plugin Author berkux

    (@berkux)

    Hi,

    try

    [jsoncontentimporter url=https://api.json-content-importer.com/extra/json/gafco.json]
    {subloop:current:-1}
    last_updated_epoch: {last_updated_epoch}<br>
    {subloop:current.condition:-1}Condition: {current.condition.text}{/subloop:current.condition}
    {/subloop:current}
    [/jsoncontentimporter]

    This gives us https://wptest.kux.de/gafco/

    Bernhard

    Thread Starter gafco

    (@gafco)

    when I put your code in the widget it did not work, but when I added it to a custom HTML it seem to work. Can I not use the widget for to get this data?

    Plugin Author berkux

    (@berkux)

    Hi,

    when I put your code in the widget

    What Do you mean by “widget”?

    Using a Shortcode in a Widget like CustomHTML is the way it should work.

    Bernhard

    • This reply was modified 3 years, 9 months ago by berkux.
    Thread Starter gafco

    (@gafco)

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘subloop-array Problem’ is closed to new replies.