Custom Post Type: Linking Terms to show Count

One way which would seem inefficient ( but at the moment I cannot think of a way without re-querying the database ) is to Query each term as you loop. You’ll be making many more queries so we’ll limit what is returned to try and speed them up.

if ( $features_count > 0 ) {
  ?>

    <div class="more-options-wrapper clearfix">

      <?php foreach ($all_features as $feature ) {
            $count = $feature->count;

            if( ! empty( $required_features_slugs ) ) {
                $tmp_required = $required_features_slugs;

                if( ! in_array( $feature->slug, $required_features_slugs ) ) {
                    array_push( $tmp_required, $feature->slug );
                }

                $tmp_query = new WP_Query( array(
                    'posts_per_page'    => -1,
                    'fields'            => 'ids',           // Only return post IDs
                    'tax_query'         => array( array(
                        'taxonomy'  => 'features',
                        'field'     => 'slug',
                        'terms'     => $tmp_required,
                    ) ),
                ) );

                $count = ( $tmp_query->have_posts() ) ? count( $tmp_query->posts ) : 0;
            }
      ?>

            <div class="option-bar">
                <input type="checkbox"
                       id="feature-<?php echo $feature->slug; ?>"
                       name="features[]"
                       value="<?php echo $feature->slug; ?>" onclick="document.getElementById('refine-properties').submit();"
                    <?php if ( in_array( $feature->slug, $required_features_slugs ) ) { echo 'checked'; } ?> />
                <label for="feature-<?php echo $feature->slug; ?>"><?php echo $feature->name; ?> <small>(<?php echo $count; ?>)</small></label>
            </div>

      <?php } ?>

    </div>

  <?php
}

What we’re doing is that if one or more categories are selected we’re going to loop through the categories and append the current slug. Then we’re querying the database for posts that have our required categories plus the current category. Finally, we only return post IDs for speed purposes – if we have posts we count them otherwise it’s 0.