Created
July 7, 2015 17:21
-
-
Save nicdford/3ecb45803e0935cf9b49 to your computer and use it in GitHub Desktop.
Control output of looped items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*========== 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