Created
June 3, 2015 11:37
-
-
Save remyperona/ba5d8d9705342b480e4a to your computer and use it in GitHub Desktop.
geo-mashup-nearby-list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Variables in scope: | |
* $geo_mashup_search object The managing search object | |
* $search_text string The search text entered in the form | |
* $radius int The search radius | |
* $units string 'mi' or 'km' | |
* $object_name string 'post' or 'user' or 'comment' | |
* $near_location array The location searched, including 'lat' and 'lng' | |
* $distance_factor float The multiplier to convert the radius to kilometers | |
* $approximate_zoom int A guess at a zoom level that will include all results | |
* | |
* Methods of $geo_mashup_search mimic WordPress Loop functions have_posts() | |
* and the_post() (see http://codex.wordpress.org/The_Loop). This makes post | |
* template functions like the_title() work as expected. For distance: | |
* | |
* $geo_mashup_search->the_distance(); | |
* | |
* will echo the distance with units. Its output can be modified: | |
* | |
* $geo_mashup_search->the_distance( 'decimal_places=1&append_units=0&echo=0' ); | |
*/ | |
?> | |
<?php if ( $geo_mashup_search->have_posts() ) : ?> | |
<aside> | |
<ul class="geo-mashup-nearby-posts"> | |
<?php if ($object_name == 'post'):?> | |
<?php while ( $geo_mashup_search->have_posts() ) : $geo_mashup_search->the_post(); ?> | |
<li> | |
<a href="<?php the_permalink(); ?>" title=""><?php the_title(); ?></a> | |
<span class="distance"><?php $geo_mashup_search->the_distance(); ?></span> | |
</li> | |
<?php endwhile; ?> | |
<?php elseif ($object_name == 'user'):?> | |
<?php while ( $geo_mashup_search->have_posts() ) : $user=$geo_mashup_search->get_userdata(); ?> | |
<li> | |
<?php echo $user->first_name.' '.$user->last_name;?> aka <?php echo $user->user_nicename?> | |
<span class="distance"><?php $geo_mashup_search->the_distance(); ?></span> | |
</li> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</ul> | |
</aside> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment