Add up all numbers from a WordPress query [closed]

.= does string concatention, eg, 'hello ' . 'world' gets you hello world.

To add, use + instead of .:

// Set a default for $numbers.
$numbers = 0;

$query = new WP_Query($args);

if ($query->have_posts()) {

    while ($query->have_posts()) {
        $query->the_post();

        $post_id    = get_the_ID();
        $party_size = get_field('reservation_party_size', $post_id);

        $numbers    += intval( $party_size );
    }

}

return $numbers;

I use intval() to make sure that $party_size is an integer.

More reading: PHP Assignment Operators

techhipbettruvabetnorabahisbahis forumutaraftarium24edueduedueduedusedusedusedueduedus