Viewing 1 replies (of 1 total)
  • If these are held in custom fields, they are most likely stord in the wp_postmeta table and are related to the post ID. You’ll need to know the name of each one, and you’ll be able to do this. As a pure example without knowing what the fields are called…

    This is a slightly innefficient way of doing it, but it pretty much explains what you’ll need to add into your code.

    $criteria_1 = get_post_meta ($post->ID, 'criteria_1', true);
    $criteria_2 = get_post_meta ($post->ID, 'criteria_2', true);
    $criteria_3 = get_post_meta ($post->ID, 'criteria_3', true);
    $criteria_4 = get_post_meta ($post->ID, 'criteria_4', true);
    $criteria_5 = get_post_meta ($post->ID, 'criteria_5', true);
    $criteria_6 = get_post_meta ($post->ID, 'criteria_6', true);
    $criteria_7 = get_post_meta ($post->ID, 'criteria_7', true);
    
    $average = ceil ($criteria_1 + $criteria_2 + $criteria_3 + $criteria_4 + $criteria_5 + $criteria_6 + $criteria_7) / 7;
Viewing 1 replies (of 1 total)
  • The topic ‘Add and Average Custom Fields’ is closed to new replies.