Display Repeater Fields
-
Hi, I am using you plugin and have looked at previous topics and your videos but I cannot get they repeater fields to display.
I have a Custom Post Type POD called ‘products’ with a field called ‘growth_promotion’. The additional field options for ‘growth_promotion’ is set to PODS table called ‘product_growth_promotion’.
‘product_growth_promotion’ Is a Advanced Content Type POD with two fields in, growth_name and growth_type.
I am using a single page template called single-product.php. I am not using the while loop and this is how I display the standard POD fields:
global $post;
$product = pods(‘product’, $post->ID);
echo $product->display(‘product_name’);How do I display the fields from the repeater? I have tried:
print_r( pods_field(‘product’, $post->ID, ‘growth_promotion’) );
print_r( pods_field(‘product’, $post->ID, ‘product_growth_promotion’) );
print_r( pods_field(‘product_growth_promotion’, $post->ID, ‘growth_promotion’) );
print_r( pods_field(‘product_growth_promotion’) );
print_r( pods_field(‘growth_promotion’) );
None of these output anything. Some will display an empty array but still no values inside.
-
Hi @snookian
Thanks for using the plugin. Can I double check: is the pod name ‘products’ or ‘product’. If it is ‘products’, it has to be pods_field(‘products’, $post->ID, ‘growth_promotion’).
If it is ‘product’. would you please use Pods’ Migrate: Packages component to export the relevant pods for me so I can test it on my computer?
Hi @codingpanda, thank you for the reply. The pod name is ‘product’ , I made a type in my original questions.
So pods_field(‘product’, $post->ID, ‘growth_promotion’) doesn’t do anything and when is use it in print_r() it just shows: Array ( ) 1
Here is the export info, hopefully I did this right:
{"meta":{"version":"2.7.27","build":1620907051},"pods":{"123":{"id":123,"name":"notification","label":"Notifications","description":"","type":"post_type","storage":"meta","object":"","alias":"","fields":{"notification_name":{"id":124,"name":"notification_name","label":"Notification Name","description":"","help":"","class":"","type":"text","weight":0,"pick_object":"","pick_val":"","sister_id":"","required":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","text_repeatable":"0","text_placeholder":""},"notification_file":{"id":125,"name":"notification_file","label":"Notification File","description":"","help":"","class":"","type":"file","weight":1,"pick_object":"custom-simple","pick_val":"","sister_id":"","required":"1","file_format_type":"single","file_uploader":"plupload","file_attachment_tab":"upload","file_edit_title":"1","file_show_edit_link":"0","file_linked":"1","file_limit":"0","file_restrict_filesize":"10MB","file_type":"other","file_allowed_extensions":"pdf","file_field_template":"rows","file_add_button":"Add File","file_modal_title":"Attach a file","file_modal_add_button":"Add File","file_wp_gallery_output":"0","file_wp_gallery_link":"post","file_wp_gallery_columns":"1","file_wp_gallery_random_sort":"0","file_wp_gallery_size":"thumbnail","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0"}},"show_in_menu":"1","label_singular":"Notification","public":"1","show_ui":"1","supports_title":"1","supports_editor":"1","publicly_queryable":"1","exclude_from_search":"0","capability_type":"post","capability_type_custom":"notification","capability_type_extra":"1","has_archive":"1","hierarchical":"0","rewrite":"1","rewrite_with_front":"1","rewrite_feeds":"0","rewrite_pages":"1","query_var":"1","can_export":"1","default_status":"draft","supports_author":"0","supports_thumbnail":"0","supports_excerpt":"0","supports_trackbacks":"0","supports_custom_fields":"0","supports_comments":"0","supports_revisions":"0","supports_page_attributes":"0","supports_post_formats":"0","built_in_taxonomies_category":"0","built_in_taxonomies_link_category":"0","built_in_taxonomies_post_tag":"0","built_in_taxonomies_wpdmcategory":"0","menu_position":"7","show_in_nav_menus":"1","show_in_admin_bar":"1","pfat_enable":"0","pfat_append_single":"append","pfat_filter_single":"the_content","pfat_append_archive":"append","pfat_filter_archive":"the_excerpt","pfat_run_outside_loop":"0","rest_enable":"0","read_all":"0","write_all":"0","label_archives":"Notifications","label_items_list_navigation":"Notifications","label_items_list":"Notifications"},"87":{"id":87,"name":"product","label":"Products","description":"","type":"post_type","storage":"table","object":"","alias":"","fields":{"catalogue_no":{"id":88,"name":"catalogue_no","label":"Catalogue Nod","description":"","help":"","class":"","type":"text","weight":0,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","text_repeatable":"0","text_placeholder":""},"product_type":{"id":89,"name":"product_type","label":"Product Type","description":"","help":"","class":"","type":"text","weight":1,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","text_repeatable":"0","text_placeholder":""},"unit_size":{"id":90,"name":"unit_size","label":"Unit Size","description":"","help":"","class":"","type":"text","weight":2,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","text_repeatable":"0","text_placeholder":""},"description":{"id":91,"name":"description","label":"Description","description":"","help":"","class":"","type":"text","weight":3,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","text_repeatable":"0","text_placeholder":""},"storage_temp":{"id":92,"name":"storage_temp","label":"Storage Temp","description":"","help":"","class":"","type":"text","weight":4,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","text_repeatable":"0","text_placeholder":""},"ph_value":{"id":93,"name":"ph_value","label":"pH Value","description":"","help":"","class":"","type":"text","weight":5,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","text_repeatable":"0","text_placeholder":""},"growth_promotion":{"id":97,"name":"growth_promotion","label":"Growth Promotion","description":"","help":"","class":"","type":"pandarepeaterfield","weight":6,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","pick_post_status":["publish"],"pandarepeaterfield_table":"product_growth_promotion","pandarepeaterfield_field_width":"50","pandarepeaterfield_entry_limit":"0","pandarepeaterfield_enable_load_more":"0","pandarepeaterfield_initial_amount":"10","pandarepeaterfield_enable_trash":"0","pandarepeaterfield_order_by":"pandarf_order","pandarepeaterfield_order":"ASC","pandarepeaterfield_display_order_info":"0","pandarepeaterfield_apply_admin_columns":"0","pandarepeaterfield_allow_reassign":"0","pandarepeaterfield_public_access":"0","subscriber":"0","admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2"},"show_inab":{"id":94,"name":"show_inab","label":"Show INAB Cert","description":"","help":"","class":"","type":"boolean","weight":7,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","pick_post_status":["publish"],"boolean_format_type":"checkbox","boolean_yes_label":"Yes","boolean_no_label":"No","admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2"},"show_ce":{"id":95,"name":"show_ce","label":"Show CE Cert","description":"","help":"","class":"","type":"boolean","weight":8,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","pick_post_status":["publish"],"boolean_format_type":"checkbox","boolean_yes_label":"Yes","boolean_no_label":"No","admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2"},"show_quantity":{"id":96,"name":"show_quantity","label":"Show Min Quantity Message","description":"","help":"","class":"","type":"boolean","weight":9,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","pick_post_status":["publish"],"boolean_format_type":"checkbox","boolean_yes_label":"Yes","boolean_no_label":"No","admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2"}},"show_in_menu":"1","label_singular":"Product","public":"1","show_ui":"1","supports_title":"1","supports_editor":"1","publicly_queryable":"1","exclude_from_search":"0","capability_type":"post","capability_type_custom":"product","capability_type_extra":"1","has_archive":"1","hierarchical":"0","rewrite":"1","rewrite_with_front":"1","rewrite_feeds":"0","rewrite_pages":"1","query_var":"1","can_export":"1","default_status":"draft","supports_author":"0","supports_thumbnail":"0","supports_excerpt":"0","supports_trackbacks":"0","supports_custom_fields":"0","supports_comments":"0","supports_revisions":"0","supports_page_attributes":"0","supports_post_formats":"0","built_in_taxonomies_category":"0","built_in_taxonomies_link_category":"0","built_in_taxonomies_post_tag":"0","menu_position":"4","show_in_nav_menus":"1","show_in_admin_bar":"1","pfat_enable":"0","pfat_append_single":"append","pfat_filter_single":"the_content","pfat_append_archive":"append","pfat_filter_archive":"the_excerpt","pfat_run_outside_loop":"0","rest_enable":"0","read_all":"0","write_all":"0","built_in_taxonomies_wpdmcategory":"0","label_archives":"Products","label_items_list_navigation":"Products","label_items_list":"Products"},"98":{"id":98,"name":"product_growth_promotion","label":"Products Growth Promotion","description":"","type":"pod","storage":"table","object":"","alias":"","fields":{"growth_name":{"id":104,"name":"growth_name","label":"Growth Name","description":"","help":"","class":"","type":"text","weight":0,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"text_repeatable":"0","text_placeholder":""},"growth_type":{"id":105,"name":"growth_type","label":"Growth Type","description":"","help":"","class":"","type":"boolean","weight":1,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","pick_post_status":["publish"],"boolean_format_type":"dropdown","boolean_yes_label":"Inhibition","boolean_no_label":"Growth","admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"]}},"show_in_menu":"0","label_singular":"Product Growth Promotion","pod_index":"growth_name","hierarchical":"0","ui_style":"post_type","menu_position":"0","ui_actions_enabled":["add","edit","duplicate","delete"],"ui_reorder_field":"menu_order","ui_fields_manage":{"0":"name","2":"modified"}}}}
Hi @snookian
I imported your settings, and the following code works for me.
global $post; print_r( pods_field('product', $post->ID, 'growth_promotion') );
https://www.dropbox.com/s/xkvw51elh84toxi/growth-backend.png?dl=0
https://www.dropbox.com/s/8l21g32bfa527h4/growth-frontend.png?dl=0Could you make sure $post->ID returns the current post ID?
Hi @codingpanda There must be a setting or something I am not selecting. I deleted the POD and started again and still get a empty array. I deleted the repeater pod and calld in growth_pod and changed the field in the main field to just growth incase it was caused issue using the same names.
The post ID is correct as when I echo $post->ID I get the correct product ID. Maybe I need to search for an alternative plugin.
-
This reply was modified 3 years, 10 months ago by
snookian.
Could it be because I am using PHP8 with WordPress 5.7.2?
Hi @snookian
You are a star! Yes, it is because of PHP 8. I will get that sorted.
Before I release a new version, you could go to panda-pods-repeater-field.php, line 731 and change
if( $atts_arr['limit'] != '' ){
toif( ! empty( $atts_arr['limit'] ) ){
That will fix the problem.
Hi @snookian, I have released a version with the fix. Please let me know if the problem still occurs.
-
This reply was modified 3 years, 10 months ago by
- The topic ‘Display Repeater Fields’ is closed to new replies.