one3rdnerd: thanks for sharing this! Most helpful.
For anyone who’s trying to add a repeater field using the templates that are built into PODS, this extends the shortcode function; tested & worked for me!
1. Edit/customize and paste the function below into the functions.php file in your custom theme to output an array including ALL fields. Why? It outputs a list of all the fields needed to edit the Repeater Fields function (the second function listed below). Note: change “name-of-the-pods-table-as-repeater-field” to the name shown in the Fields tab in your Pods Admin screen.
// Use this to output an array including ALL fields
function repeater_shortcode() {
global $post;
echo '<pre>';
print_r( pods_field('name-of-the-pods-table-as-repeater-field'));
echo '</pre>';
}
add_shortcode('repeater', 'repeater_shortcode');
// end function
2. Paste the shortcode [repeater] into the template window in PODS (and save).
3. Open the page on the front end, and copy and paste the output into a text file, so you have a list of all the available fields – shown in square brackets.
4. Comment out or remove the function above. Then paste in and edit/customize this new function:
/* Repeater Fields */
function repeater_shortcode($atts) {
global $post;
ob_start();
$repeater = pods_field('name-of-the-pods-table-as-repeater-field');
if(!empty($repeater)) {
echo "<h2 class='repeater-heading'>This Optional Subheading Appears Above the Repeater Fields</h2>";
}
foreach($repeater as $val) {
echo "<div class='repeater-block-container'>";
echo "<h3 class='available-field-1'>" . $val['available-field-1'] . "</h3>";
echo "<p class='available-field-2'>" . $val['available-field-2'] . "</p>";
echo "<p class='available-field-3'>" . $val['available-field-3'] . "</p>";
echo "</div>";
}
return ob_get_clean();
}
add_shortcode('repeater', 'repeater_shortcode');
// end function
5. Make sure to customize ‘name-of-the-pods-table-as-repeater-field’ (same as you did for the first function) and replace the ‘available-fields’ with the ones shown in square brackets output from the first function. The HTML and class names can be modified as needed.
6. The shortcode is the same, so you don’t need to do anything other than save and upload functions.php
Hope this helps if you’re trying to get repeater fields working with the built-in PODS templates…