Can I create a custom WP_Query using lat/lon and near radius?

This topic contains 3 replies, has 3 voices, and was last updated by  Aleks Szymanski 1 year, 1 month ago.

  • Author
    Posts
  • #496119

    Aleks Szymanski
    Full Member
    Post count: 23

    I’m wanting to create a custom loop that populates Places (gd_place cpt) based on lat/lon. I’ve tried this so far but it doesn’t work:

    
    
    $places = new WP_Query(array(
    	'post_type' 		=> 'gd_place',
    	'sgeo_lat'			=> '34.989220800000005',
    	'sgeo_lon'			=> '-85.3525126'
    ));
    
    if ( $places->have_posts() ) :
    
    	while ( $places->have_posts() ) : $places->the_post();
    	
    		echo '<h2>'.get_the_title().'</h2>';
    	
    	endwhile; wp_reset_postdata();
    	
    endif;
    
    

    Is there something I’m missing?

    Also, would like to filter these results by changing the near radius value to 30(miles) instead of the default setting (15).

    Any help here would be appreciated, thanks!

    #496163

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    I will flag your topic for the developers in case they can provide any advice for you.

    However, since we do not provide support here for customizations in the forum, I recommend you contact one of the experts here:

    https://geodirectoryexperts.com

    #496186

    Kiran
    Moderator
    Post count: 7069

    Hello Aleks,

    There is not way at the moment to retrieve posts by using latitude & longitude via WP_Query. But we have already have a task to implement this via API.

    Kiran

    #496432

    Aleks Szymanski
    Full Member
    Post count: 23

    Ok thanks guys.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Can I create a custom WP_Query using lat/lon and near radius?’ is closed to new replies, this may be for inactivity, please open a new topic if you have a similar question.