Home Forums Front-end Issues Repeater Returning Type boolean instead of Array


Repeater Returning Type boolean instead of Array

  • I am trying to count the number of rows in an array, the snip I found online everywhere as an example is:
    $numrows = count(get_field(‘repeating_content’));

    When I try to use this I get this error:
    Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given…

    When I use echo gettype the output is boolean

    I am able to output the content of the repeater without any errors despite this mismatched type.

    Any insight would be appreciated.

  • Seems like the get_field(‘repeating_content’) function is returning a boolean value instead of an array. Maybe you can check if the field exists and if it’s returning the expected value.

    $repeating_content = get_field(‘repeating_content’);

    // Check if $repeating_content is an array before counting its rows
    if (is_array($repeating_content)) {
    $numrows = count($repeating_content);
    echo “Number of rows: $numrows”;
    } else {
    echo “Error: Unable to retrieve repeating content.”;

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.