Support

Account

Home Forums Front-end Issues How to get sum of custom field value without display them in frontend ?

Solved

How to get sum of custom field value without display them in frontend ?

  • I use JavaScript get sum of a custom field value
    <?php the_field(‘length’); ?>
    in archive.php.

    It looks OK, but when there are lots of posts in current category. For example if there are 200 hundred posts in current category, i can’t show them all in one page, so i can’t get sum of coustom field value.

    So, is there some way I can get sum of custom field value without display them in frontend?

  • Not 100% sure what you mean. If this field is for a post and you want to get the sum of all fields for all posts then you must do a query to get all the posts, loop over them, get the field value an add them up. You don’t need to show the posts but you still need to get them and loop over them.

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

The topic ‘How to get sum of custom field value without display them in frontend ?’ is closed to new replies.