Proximity facet: show post distance
When using the proximity facet, it’s now possible to show each post’s distance from the specified location.
Enable distance
Storing each post’s distance requires a little extra memory, so it’s disabled by default. To enable it, add the following to your theme’s functions.php:
add_filter( 'facetwp_proximity_store_distance', '__return_true' );
Show distance
Next, use the facetwp_get_distance
function to display the distance for each post. It returns the numeric distance if the proximity facet is in use, or FALSE.
<?php $distance = facetwp_get_distance(); if ( false !== $distance ) { echo round( $distance, 2 ); }