Home › Forums › General Issues › Calculating a sum of a number field for all posts › Reply To: Calculating a sum of a number field for all posts
Hi,
You don’t explicitly say what’s wrong with the results you’re seeing. But I can think of a few reasons that you don’t see the results you’re expecting. The most obvious one is the call to get_posts.
In the args array passed to get_posts, you don’t specify ‘numberposts’. If you leave it out, it will default to 5. If you want all posts, you need to specify -1. Please se https://developer.wordpress.org/reference/functions/get_posts/ for details.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.