Retrieving nested, or multidimensional data, can easily be achieved with the Pro Plugin.
The Pro Plugin allows you to step down through multidimensional array data using array keys and indexes to get your data. This works in both the template function and also the shortcode.
Our latest update to the PRO plugin now allows you to grab multiple array keys so that you can easily pick and choose which items from an array you want to display.
Let’s pretend that your API returned the data below. You could easily get the nickname of the first item, or you could get all nicknames, or you could get both the nickname and id of the second item. The possibilities are endless as to which data you can retrieve.
Array(
[name] => Array(
[0] => Array(
[nickname] => Cowboy,
[id] => 24538
),
[1] => Array(
[nickname] => Yeehaa,
[id] => 49890
),
[2] => Array(
[nickname] => Horse,
[id] => 14377
)
)
)
The shortcode and template functions to retrieve these various types of data would look something like this: