Support

Account

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.