Panda Pods Repeater Field

Description

Panda Pods Repeater Field is a plugin for the Pods Framework. It is more than a repeater field: it is a quick way to set up a relational database and present the data on the same page. It takes advantage of Pods table storage, so you don’t need to worry about the posts and postmeta tables expanding dramatically and slowing down page loading. This plugin is compatible with Pods Framework 2.8 or later and has been updated for WordPress 7.0 and Pods 3.3.9. To download Pods Framework, please visit https://pods.io/. After each update, please clear the cache to make sure the CSS and JS are updated. Usually, Ctrl + F5 will do the trick.

Introduction


Screenshots

Installation

  1. Upload the plugin files to the /wp-content/plugins/panda-pods-repeater-field directory, or install the plugin directly through the WordPress Plugins screen.
  2. Activate the plugin through the ‘Plugins’ screen in WordPress.
  3. Add a Panda Repeater field from the Pods field editor.

FAQ

How do I use it?

Please see the screenshots for instructions.

How do I fetch data on the front end?

From version 1.1.4, you can use pods_field(). For example, in a single post template, use pods_field( ‘field_name’ ) to fetch data for the current page. Otherwise, use pods_field( ‘pods_name’, ‘post_id’, ‘field_name’ ) to fetch data anywhere. To fetch data from the settings area, use pods_field( ‘pods_name’, false, ‘field_name’ ). To fetch data from the users area, use pods_field( ‘user’, ‘user_id’, ‘field_name’ ).

You can use these filters to alter the repeater data returned from pods_field(): pandarf_pods_field_attrs( array(), $value_ukn, $row_arr, $params_arr, $pods_obj ) and pandarf_data_attrs( array(), $data_arr, $parent_pod_name ).

From version 1.1.6, if the field type is “file”, it returns the file IDs. You can then use WordPress APIs like get_attached_file(), wp_get_attachment_image_src(), etc. to get the file details. Relation types of ‘user’, ‘post type’, ‘pod’ and ‘media’ return the saved ID.

You can also use this API to fetch data: pandarf_items_fn( $fields_arr, $attrs, $show_query ). Please see the Screenshots section for how to find IDs.

Use $fields_arr to search the repeater field table:
array(
‘id’ => ”, // row ID
‘name’ => ”, // the common name field used by Pods
‘child_pod_name’ => ”, // repeater table name
‘parent_pod_id’ => ”,// main table Pod ID
‘parent_pod_post_id’ => ”, // main table post ID
‘parent_pod_field_id’ => ”, // main table Panda Pods Repeater Field ID
)

$attrs supports some basic MySQL commands (optional):
array(
‘where’ => ”, // extra WHERE clause, expected to be escaped
‘order’ => ‘ASC’,
‘order_by’ => ‘pandarf_order’,
‘group_by’ => ”,
‘start’ => 0,
‘limit’ => 0,
‘count_only’ => false, // if true, it will return the number of rows in an array.
‘add_tb_prefix’ => true, // add $table_prefix to the table name. Defaults to true
)

$show_query
If set to true, it will print the SQL command for debugging. Defaults to false.

Basic usage example. The IDs are from the Screenshots section:
get_pandarf_items( array( ‘child_pod_name’ => ‘comic_item’, ‘parent_pod_id’ => 2273, ‘parent_pod_post_id’ => 2275, ‘parent_pod_field_id’ => 2274 ) );
Use pandarf_items_fn for versions before v1.4.11.

This returns the Comic Contents items attached to the post.

How do I insert data on the front end?

You can use this API to insert data: pandarf_insert( $fields_arr, $prf_arr, $show_query ). Please see the screenshots for how to find IDs.

Use $fields_arr for extra fields other than Panda Repeater fields:
array(
‘field_name’ => ”,
‘field_name’ => ”
… …
)
Use $prf_arr for the default repeater fields:
array(
‘child_pod_name’ => ”, // The name of the table for saving repeater field items.
‘parent_pod_id’ => ”, // main table Pod ID
‘parent_pod_post_id’ => ”, // main table post ID
‘parent_pod_field_id’ => ”, // main table Panda Pods Repeater Field ID
‘user_id’ => 0 // The author ID
‘add_tb_prefix’ => true, // add $table_prefix to the table name. Defaults to true
)

$show_query
If set to true, it will print the SQL command for debugging. Defaults to false.

This API returns the inserted row ID if successful, or false on failure.

Basic usage example. The IDs are from the Screenshots section:
$id_int = pandarf_insert( array( ‘name’ => “hello panda” ), array( ‘child_pod_name’ => ‘comic_item’, ‘parent_pod_id’ => 2273, ‘parent_pod_post_id’ => 2275, ‘parent_pod_field_id’ => 2274, ‘user_id’ => $current_user->ID ) );

/**
* The repeater field is only for logged-in users with the edit_posts capability
* If you want it to be available to front-end users, you can use this filter
*
* @param boolean $is_allowed Whether to allow the form to be displayed.
* @param array $get_arr Variables from $_GET.
* @return boolean Whether access is allowed.
*/
function pprf_allow( $is_allowed, $get_arr ){

$pod_obj    =   pods('your_pod_slug');      
if( $get_arr['podid'] == $pod_obj->pod_id ){
    $is_allowed = true;
}
return  $is_allowed;

}

How do I remove the CSS and JavaScript enqueued by the plugin on the front end?

Add this code to your functions.php:

add_action( ‘wp_enqueue_scripts’, ‘dequeue_scripts_and_styles’, 11 );

function dequeue_scripts_and_styles() {
wp_dequeue_script( ‘panda-pods-repeater-scripts’ );
wp_dequeue_style( ‘panda-pods-repeater-general-styles’ );
wp_dequeue_style( ‘panda-pods-repeater-styles’ );
}

Reviews

April 16, 2024
Quite a complex setup, but really like the fact it uses separate tables rather than more meta (like all the others). I feel the extra time setting it up is worth it on most of my projects that don’t quite need a custom built plugin. I think it’s great, but you do need to know what you’re doing – definitely not something for the no-code “developer” 😉 Sure there’s people saying don’t use this as Pods will support it in a proper way… but it’s been over 6 years since, and there’s still no way to do a real ACF style repeater with Pods other than with this add-on (or coding it yourself). Sorry simple repeater fields just don’t cut it. I love Pods and the way it allows you to create your own tables, but the lack of a proper repeater kills me on so many sites I want to use it on, so I’ve gotta say thanks Panda Pods for keeping this updated!
March 24, 2023 1 reply
Overall a great plugin since Pods is still missing a repeater functionality that allows nested fields (like the ACF Repeater).However, the user interface of this plugin, especially for content editors, is just a big mess and would need a redesign. Oh and to anyone who stumbles upon this using Pods 2.9+ : It’s important that you enable at least “Advanced Content Types” in “Pods Admin” > “Components” to follow the instructions of this plugin. I cannot believe how much time i wasted to find this setting. As a developer, i have a totally different understanding of what a “Component” is and the Pods documentation just sucks.
December 22, 2021 2 replies
Utilizing this plugin, you’re able to use your Pods in a mind-blowing way, which to me was so much better than trying the other ones! Also, if you need any questions, you’ll get your answers in a jiffy by the authors, which is fantastic!
November 25, 2020 1 reply
Le plugin fonctionne parfaitement. Il permet de mettre en place une répétition de champs avec PODS. Merci aux contributeurs pour mise à disposition de cet outil librement. +++
November 13, 2017 2 replies
unable to get the data from repeater fields follow every steps as shown in the images instruction ,i made the Advanced Content Type (project_image) and create two fields for repeater 1.project_image 2.position and add this in custom post type (project), i added the field Pods Table As Repeater Field (projects_box) and choosed in additional field option project_image, everything is working fine but unable to fetch these fields data at frondend. kindly help me with this. Regards, Zeeshan
Read all 11 reviews

Contributors & Developers

“Panda Pods Repeater Field” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.0.1 – 23rd September 2016

  • Added: A filter to display item titles.

1.0.2 – 30th September 2016

  • Added: Support for pandarf_items_fn to search ID and name fields.
  • Added: A notice telling users to refresh pages after reordering.

1.0.3 – 5th October 2016

  • Added: Support for a custom WHERE query in pandarf_items_fn.

1.0.4 – 6th October 2016

  • Fixed: pandarf_parent_post_id now uses numbers only; previously it used a string.

1.0.5 – 14th October 2016

  • Fixed: Ordering for newly added items.

1.0.6 – 21st October 2016

  • Fixed: An issue on the user profile page.

1.0.7 – 28th October 2016

  • Fixed: An issue when using the plugin within Advanced Content Types.

1.0.8 – 2nd November 2016

  • Fixed: Ordering by pandarf_order on the front end by casting the string as a number.

1.0.9 – 2nd November 2016

  • Changed: Time format from h:i:s to H:i:s.

1.1.0 – 1st December 2016

  • Added: The add_tb_prefix parameter to the pandarf_items_fn() and pandarf_insert APIs so they can be used for all tables.
  • Added: The pods_post_delete() action to pods_api_post_delete_pod_item.
  • Added: The pprf_action_pods_post_delete() action to pods_post_delete.
  • Added: The pprf_filter_pods_post_delete() filter to pods_api_post_delete_pod_item.
  • Added: The pprf_action_pods_post_save() action to pods_post_save.
  • Added: The pprf_filter_pods_post_save() filter to pods_api_post_delete_pod_item.
  • Added: Auto-expanding when adding and editing an item.
  • Updated: The interface.

1.1.1 – 4th March 2017

  • Fixed: An issue where, after deleting an item, the label still stayed.
  • Updated: The interface.

1.1.2 – 22nd April 2017

  • Added: New close and expand bars on the top and bottom.
  • Changed: Moved the delete button from the iframe to the parent window.
  • Changed: Simplified reordering.

1.1.3 – 13th May 2017

  • Added: A Save button on the bar.
  • Fixed: Inserting pandarf_order on the front end by casting the string as a number.
  • Removed: The add_action( ‘save_post’, array( $tableAsRepeater_cla, ‘update_child_pod’ ), 10, 3 ) call, which is no longer needed.

1.1.4 – 29th June 2017

  • Added: The is_pandarf_fn( $fieldName_str ) API to check if a field is a Panda Pods Repeater Field.
  • Added: The pandarf_get_data( $data_arr, $parent_pod_name ) API to fetch repeater data for a data row from a database table.
  • Added: Integration with pods_field().

1.1.5 – 9th July 2017

  • Fixed: An issue where a newly created item fetched data from other parent posts when using pods_field.

1.1.6 – 5th August 2017

  • Added: Returning file and user IDs for relation types of ‘user’, ‘post type’, ‘pod’ and ‘media’.
  • Added: Support for limiting the number of entries.

1.1.7 – 19th August 2017

  • Fixed: An issue where the “Add New” button disappeared if the number of entries was set to 0.

1.1.8 – 15th October 2017

  • Changed: The plugin now uses pods_register_field_type() to register Panda Pods Repeater Field.
  • Fixed: Some styling issues.
  • Fixed: The Pods relationship field ordering issue.
  • Added: Alerts when changes are not saved.

1.1.9 – 22nd October 2017

  • Fixed: An issue where expanding and collapsing called pprf_resize_window() too many times, sometimes before the iframe was ready.
  • Added: The ability to move items to Trash and restore them from Trash.

1.2.0 – 17th December 2017

  • Changed: The plugin now saves the table post_name instead of ID to solve migration issues. This will not affect saved data, but you will need to update the field in Pods and choose the correct table again to migrate properly.
  • Fixed: An issue where using the same field name in two tables did not return the right data.

1.2.1 – 5th March 2018

  • Security: Enhanced AJAX security.
  • Added: Support for front-end Pods forms.
  • Fixed: Newly added items could only be deleted, not moved to Trash.

1.3.0 – 27th July 2018

  • Added: Load More functionality.
  • Added: Order options.
  • Updated: Reordering now updates colours.
  • Changed: Some code according to Pods official reviews.

1.3.1 – 19th August 2018

  • Changed: Drag-and-drop tolerance from “pointer” to “intersect”.
  • Fixed: An issue where only ten items were loaded when Enable Load More was set to No.

1.3.2 – 23rd September 2018

  • Fixed: The date field display issue.

1.3.3 – 29th October 2018

  • Fixed: pods->delete() did not work reliably, so a $wpdb query is used for now.

1.3.4 – 3rd November 2018

  • Fixed: An issue with pods->delete().
  • Added: Support for using Admin Table Columns for labels.

1.3.5 – 18th November 2018

  • Fixed: An issue where pandarf_items_fn did not respond when the order field was changed.
  • Fixed: A typo.

1.3.6 – 19th November 2018

  • Fixed: An issue where an empty order field loaded data in descending order.
  • Changed: Adjusted some icons’ padding and margin.

1.3.7 – 9th December 2018

  • Fixed: An issue where pods_field() did not fetch data in AJAX.

1.3.8 – 10th March 2019

  • Updated: Optimised some code.
  • Added: The ability to reassign an item to another parent field using the same child table.

1.4.0 – 24th March 2019

  • Changed: How a repeater field is rendered so it can be displayed on the front end for non-logged-in users.
  • Changed: Filter names from “pprf_load_panda_repeater_allow” to “pprf_load_panda_repeater_allow_input” and from “pprf_load_panda_repeater_allow_msg” to “pprf_load_panda_repeater_allow_input_msg”.
  • Changed: JavaScript from ‘live’ to ‘on’.
  • Added: The ability to allow selected user roles to access the field.
  • Fixed: An issue where the field opened and closed immediately on mobile.

1.4.1 – 20th April 2019

  • Changed: Made JavaScript alerts translatable.
  • Added: Chinese language support.
  • Fixed: An error when a Pods table did not exist.
  • Fixed: An error on multisite.
  • Fixed: An error when a repeater field is a custom post type, although using a custom post type as a repeater field is not part of the plan.

1.4.2 – 27th May 2019

  • Added: The pandarf_pods_field_fields filter.

1.4.3 – 22nd June 2019

  • Added: Locked down the font size in the form so it will not be affected by the theme.
  • Changed: $pods_obj->id to $pods_obj->id() in pandarf_pods_field() to fix an issue in the REST API.

1.4.4 – 22nd September 2019

  • Fixed: TypeError: Backbone.Marionette is undefined.
  • Fixed: $(…).live is not a function error using jQuery.

1.4.5 – 2nd November 2019

  • Added: Code to add the relationship fields if they are missing. This is useful for migrating repeater fields or creating them with code.
  • Fixed: The “$ is not a function” issue when clicking the Load button.
  • Changed: The window now resizes after running all JavaScript.

1.4.6 – 4th February 2020

  • Fixed: An issue where the trash, save, and edit buttons had to be clicked twice on mobile before they worked.
  • Added: Styling for the Load More div.
  • Added: Integration with Simpods Area Field.
  • Security: Removed all tags from label outputs and limited label text to 80 characters. If a label contains images, videos, audio, or shortcodes, relevant icons are displayed.

1.4.7 – 29th July 2020

  • Fixed: An issue where the database class was not included in the pandarf_items_fn function.

1.4.8 – 9th December 2020

  • Updated: Simpods Area Field integration for Simpods 3.0.0.
  • Added: Minified CSS and JavaScript files.
  • Added: The load_pprf_scripts_frontend filter to toggle loading PPRF scripts and styles on the front end.
  • Added: More front-end CSS.
  • Updated: JavaScript for the WordPress 5.6 update.

1.4.9 – 7th March 2021

  • Changed: index.php is now used for pandarepeaterfield.php.
  • Changed: click() to trigger(‘click’).
  • Changed: Reassign now also works for parent tables with meta storage type.
  • Updated: wp_localize_script handling for WordPress 5.7.
  • Updated: Support for Pods 2.8, which uses parent instead of pod_id.
  • Fixed: A bug in the order query.

1.4.10 – 30th March 2021

  • Added: When displaying labels with admin columns, simple relationships now display labels instead of values.
  • Fixed: A bug when using PHP 8.

1.4.11 – 21st October 2021

  • Updated: Compatibility with Pods 2.8.

1.5.0 – 21st October 2021

  • Changed: Removed _fn suffixes in function names and updated many variable names to match WordPress coding standards.
  • Fixed: An issue where a pod_index exists in the postmeta table but is not used as a field in the pod table.
  • Added: Use of the simpods_tables cache if available, to avoid duplicate queries.
  • Added: WordPress cache usage for checking if a field is a Panda Pods Repeater Field.
  • Added: When a new entry is added, it will use the admin columns if required.

1.5.1 – 12th February 2022

  • Fixed: The sorting issue caused by WordPress 5.9.

1.5.2 – 26th March 2022

  • Fixed: The sorting issue in settings caused by WordPress 5.9.
  • Fixed: An issue where pandarf_insert could not insert files.
  • Fixed: The integration issue after Pods 2.8.
  • Fixed: An issue where the “Please save the parent first” message stopped appearing.
  • Fixed: An issue where the child pod became available when the parent was not saved.
  • Fixed: An issue where a newly added item could not display admin columns.

1.5.3 – 4th December 2022

  • Added: The pprf_parent_filter_conditions() filter to filter the parent dropdown for reassignment and duplication.
  • Added: Duplication functionality.
  • Added: Functionality to delete item descendants when a parent item is deleted.
  • Added: A constant to toggle deleting item descendants, so users see the reminder to create backups before using it.
  • Added: IDs to the parents dropdown list.

1.5.4 – 6th December 2022

  • Updated: Applied coding standards.

1.5.5 – 22nd December 2022

  • Updated: Applied more coding standards.

1.5.6 – 23rd December 2022

  • Updated: Applied more coding standards.

1.5.7 – 23rd December 2022

  • Updated: Applied more coding standards.

1.5.8 – 29th December 2022

  • Removed: Front-end access.

1.5.9 – 29th December 2022

  • Updated: Re-organised the positions of some code.

1.5.10 – 12th February 2023

  • Fixed: An issue where custom database fields were not created after Pods 2.7.

1.5.11 – 30th April 2023

  • Fixed: An issue where items were also fetched from Trash.
  • Updated: Removed the instructions for using the repeater form on the front end.

1.5.12 – 8th April 2024

  • Fixed: An issue where the repeater field table was saved as 0 when there was only one.

1.5.13 – 21st May 2026

  • Security: Removed unauthenticated AJAX endpoints and added capability checks to repeater AJAX actions.
  • Security: Hardened dynamic SQL table and field identifiers used by Pods repeater queries.
  • Updated: Confirmed compatibility with WordPress 7.0 and updated the tested release metadata.
  • Updated: Raised the plugin PHP requirement to PHP 7.4+ to match the WordPress 7.0 minimum while keeping PHP 8.x compatibility.
  • Fixed: Corrected a gmdate() typo in pandarf_insert().

1.5.14 – 2nd June 2026

  • Fixed: Allowed hyphenated Pods/Panda repeater table identifiers, such as multi-choice, while continuing to reject unsafe SQL identifier characters.
  • Updated: Confirmed compatibility with Pods 3.3.9.