Hello
I am working on a way of extracting the latitude and longitude from a Jet Form filed.
If user goes to Google Maps and right clicks on the point of the map they can copy the lat/long coordinates. This value is then pasted into a form field called ‘location’.
When the post is displayed, I want to use the lat and long substrings of location to enter into a map widget.
This is what I have done so far, but I know something is missing. The Custom Post Type is called bid-packages.
add_shortcode(‘latitude’, ‘getLat()’);
function getLat($post){
$location = $post->locaton;
$lat = strstr($location, ‘,’, true);
return $lat;
}
add_shortcode(‘longitude’, ‘getLong()’);
function getLong($post){
$location = $post->location;
$long = strstr($location, ‘,’);
return $long;
}
​
You’ve typed `strstr` instead of `substr` https://www.php.net/manual/en/function.substr.php
When writing code, you should have WP_DEBUG enabled so you can see error messages. Your code would have caused an error as ‘strstr’ would not have been a defined function.
The add_shortcode function’s second argument should just be the name of your function without the ()