Getting a substring from a post meta field

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;
}

​

2 Comments
  1. The add_shortcode function’s second argument should just be the name of your function without the ()

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer