title: Average post age in days per taxonomy term
body: <p>I'm building some stats for a directory website and I got stuck calculating the average age of listings assigned to a particular listing type.</p>
  
  <p>I figured out calculating listing age in days by ID:</p>
  
  <pre><code>$today = date( 'Y-m-d' );
  $listing_date = get_the_date( 'Y-m-d', $id );
  $diff = strtotime( $today ) - strtotime( $listing_date );
  $age = round( $diff / 86400 );
  </code></pre>
  
  <p>I figured out how to pull listings assigned to a particular listing type by term ID:</p>
  
  <pre><code>$args = array(
      'posts_per_page' =&gt; -1,
      'fields' =&gt; 'ids',
      'post_type' =&gt; 'listing',
      'post_status' =&gt; 'publish',
      'tax_query' =&gt; array(
          array(
          'taxonomy' =&gt; 'listing-type',
          'field' =&gt; 'id',
          'terms' =&gt; $id
          )
      )
  );
  $ids = get_posts( $args );
  </code></pre>
  
  <p>This gives me an array of IDs of all listings assigned to a particular listing type.
  Now I need to calculate the total age in days for all those listings I retrieved IDs for.</p>
  
  <p>I figured <code>$cnt = count( $ids );</code> to get the total number of retrieved listings (IDs), but I can't figure out calculating the total age in days for those.</p>