Skip to content

Instantly share code, notes, and snippets.

@nicdford
Created July 7, 2015 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nicdford/3ecb45803e0935cf9b49 to your computer and use it in GitHub Desktop.
Save nicdford/3ecb45803e0935cf9b49 to your computer and use it in GitHub Desktop.
Control output of looped items
/*========== In Pods Template, Use Function on Field Output ==========*/
{@legend_items,add_icons}
/*========== Add to functions.php ==========*/
function add_icons($items) {
// loop through items
foreach ($items as $item) :
// Assign item values to new array
$item_icons[] = '<span class="icon-' . $item['slug'] . '" title="' . $item['name'] . '" alt="' . $item['name'] . '"></span>';
endforeach;
// implode array to control output, defaults to comma seperated list
$item_icons = implode(" ", $item_icons);
return $item_icons;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment