0

My Wordpress database somehow got messed up.

I am using ACF repeater fields and the repeater count shows zero even though I have as many as 12 repeating elements.

I am trying to update the repeater count so the field values will properly display in admin.

update  wp.sd_postmeta set meta_key = ( SELECT count(*) as count FROM wp.sd_postmeta where meta_key like 'child_products_%_sku%' and post_id = pid) where meta_key like 'child_products' and post_id = pid

or

update  wp.sd_postmeta set meta_key = ( SELECT count(*) as count FROM wp.sd_postmeta where meta_key like 'child_products_%_sku%' and post_id = pid) where meta_key like 'child_products' and post_id = pid

The question is, how do I generate a value for pid? I'd like to loop over all of the posts with a meta_key of child_products.

dingo_d
  • 11,160
  • 11
  • 73
  • 132
Bryan
  • 17,201
  • 24
  • 97
  • 123
  • What about querying first to find the pid's that contain the repeater field then running the update against only those posts? – serraosays Mar 29 '16 at 20:59
  • I could do that. Thanks for the suggestion. Was hoping I overlooked something simple though. – Bryan Mar 29 '16 at 21:18

0 Answers0