Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Created May 8, 2020 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpscholar/65478ee74ae4cb71f12f955ae6103e6b to your computer and use it in GitHub Desktop.
Save wpscholar/65478ee74ae4cb71f12f955ae6103e6b to your computer and use it in GitHub Desktop.
A custom Stellar Places template to show nearby places.
<?php
$place = Stellar_Places::get_place_object( get_post() );
$nearby = Stellar_Places::get_places(
array(
'post__not_in' => array( get_the_ID() ),
'geo_query' => array(
'lat' => $place->latitude,
'lng' => $place->longitude,
'distance' => 1,
),
)
);
$address = Stellar_Places::get_postal_address( $place );
$stellar_map = Stellar_Places::get_map( $place );
foreach ( $nearby as $location ) {
$location->icon = 'https://maps.google.com/mapfiles/ms/icons/blue-dot.png';
$stellar_map->add_location( $location );
}
$stellar_map->latitude = $place->latitude;
$stellar_map->longitude = $place->longitude;
$stellar_map->autoCenter = false;
$stellar_map->autoZoom = false;
$stellar_map->mapOptions['zoom'] = 15;
?>
<div class="stellar-places-single">
<?php $stellar_map->render(); ?>
<span class="stellar-places-postal-address formatted">
<?php $address->render(); ?>
</span>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment