I am new to this discussion board, sorry upfront 🙂
I’ve an issue with my show of my posts
Let me clarify ^^
I wish to carry out an orderby => ‘$distance’ and show the posts accordingly.
$lat2 and $lon2 are listed in wp.postmeta in meta_key and meta_value. Additionally $lat and $lon are nicely recovered with out worrie.
I attempted to place meta_key/worth in my question, nevertheless it would not work as a result of my calculation just isn’t carried out in my database.
object(WP_Query)[9785]
public 'question' =>
array (measurement=5)
'post_type' => string 'submit' (size=4)
'lon' => string '43.282' (size=6)
'lat' => string '5.405' (size=5)
'orderby' => float 4844
'order' => string 'asc' (size=3)
I’ve a metropolis filter which when clicked launches my operate. I retrieve the radius that I set to twenty.30 or 50 relying on the consumer’s choose choice
I created a post-view.php template which retrieves the discovered submit nicely, my template is a loop if $rayon<50 and there are posts it exhibits me the template a number of instances 🙂
operate filter_city(){
$rayon = $_POST['rayon'];
$lon = htmlspecialchars($_POST["lon"]);
$lat = htmlspecialchars($_POST["lat"]);
$lat2 = get_lat(get_the_id());
$lon2 = get_lon(get_the_id());
$resultat = Misc::distance($lat, $lon, $lat2, $lon2, $miles = false);
$m = spherical($resultat);
$myposts = new WP_Query([
'post_type' => 'post',
'lon' => $lon,
'lat' => $lat,
'orderby' => $m,
'order' => 'asc'
]);
$response="";
if ($myposts->have_posts()) {
whereas ($myposts->have_posts()) : $myposts->the_post();
embody('post-view.php');
endwhile;
} else {
$response .= embody('false.php');
}
I’ve tried the whole lot
Thanks upfront to your assist