Jump to content

Display distance on my posts using facetwp plugin


mohit131

Recommended Posts

I'm trying to display distance on my posts using facetwp plugin in my listify theme.

 

CODE

 

https://facetwp.com/proximity-facet-show-post-distance/

https://gist.github.com/mgibbs189/9492fcd44f135b10e92bc59e0958431c

 

Listify format for using hooks ver 2.x

 

http://listify.astoundify.com/article/545-add-additional-information-to-the-listing-grid

 

I tried this code in my function.php but getting no result.

add_filter( 'listify_get_listing_to_array', function( $data, $listing ) {
$distance = facetwp_get_distance();
if ( '' !== $distance ) {
$data['distance'] = $distance;
}
return $data;
}, 10, 2 );
add_action( 'listify_content_job_listing_meta', function() {
// Check if available.
echo '<# if ( data.distance ) { #>';

echo '<div class="fwp-distance">{{data.distance}}</div>';

echo '<# } #>';
} );

add_filter( 'facetwp_proximity_store_distance', '__return_true' );

Any suggestions will be highly appreciated :)

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.