admin管理员组文章数量:1318564
I have a CPT called medical_providers. Each medical provider has two ACF meta_fields (latitude and longitude). I want to write a wp_query to only show medical providers that are within a certain range (100 miles?) of the current user's IP address. Here is my query so far. It does not include anything related to geolocation.
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
global $wp_query;
$original_query = $wp_query;
$args = array(
'post_type' => 'medical_provider',
'posts_per_page' => 12,
'paged' => $paged,
'post_status' => 'publish',
'meta_key' => 'is_preferred',
'orderby' => 'meta_value',
'order' => 'DESC',
);
$the_query = new WP_Query( $args );
$wp_query = $the_query;
if ( $the_query->have_posts()) :
while ( $the_query->have_posts() ) : $the_query->the_post();
get_template_part( 'template-parts/medical-provider-content-post' );
endwhile;
?>
版权声明:本文标题:location search - Wordpress Query for CPT that only shows posts within radius of current user's geolocation 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742048142a2417913.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论