facetwp add distance to listify

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php

function fwp_show_distance() {
echo ‘<div class=”fwp-distance”>{{data.distance}}</div>’;
}
add_action( ‘listify_content_job_listing_meta’, ‘fwp_show_distance’, 12 );

function fwp_add_distance( $data ) {
$distance = facetwp_get_distance( $data[‘id’] );
$data[‘distance’] = ( false !== $distance ) ? round( $distance, 2 ) . ‘ miles’ : ”;
return $data;
}
add_filter( ‘listify_get_listing_to_array’, ‘fwp_add_distance’ );
add_filter( ‘facetwp_proximity_store_distance’, ‘__return_true’ );
{{/gist}}