Support

Account

Home Forums Add-ons Repeater Field Count total number of repeater rows Reply To: Count total number of repeater rows

  • So i’ve been using the syntax to get the count of a repeater’s rows from this thread successfully until I recently upgraded my PHP from 5 to 7. After upgrading to 7, I get the following warning:

    Warning: count(): Parameter must be an array or an object that implements Countable in /nfs/c06/h08/mnt/153609/domains/mydomain.com/html/wp-content/themes/mytheme/template-name.php on line 135

    The code in the template is as follows:

    <?php $count = count(get_field("locations")); ?>

    I then use the count in a conditional if/then statement.

    It all still works, but throws the warning if php error reporting is on and I like to resolve it, but not sure how.