Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Grab field from Geo My WP Plugin WordPress

  • REFUNDED

I am using the geo my wordpress plugin: https://wordpress.org/plugins/geo-my-wp/

I have a custom page template where I show the map using their shortcode. I also want to echo out the address, phonenumber for location outside of the shortcode. These fields are saved when you save the location in a custom post type.

I want to echo them out like this
<p><?php echo $address; ?></p>
<p><?php echo $phone; ?></p>

etc. for the specific location

However, I can't seem to figure out how to get the $address. It does not seem to be saved as a custom field.

Any direction would be helpful.

Answers (3)

2020-05-14

Espreson Media answers:

<p><?php echo do_shortcode( 'gmw_single_location object="post" elements="address"]' ); ?></p>
<p><?php echo do_shortcode( 'gmw_single_location object="post" location_meta="phone"]' ); ?></p>


jpequens comments:

I tried that but the phone number does not show, and displays with the full map etc. I am trying to just get the text if possible.


Espreson Media comments:

Do you want "Current Location" or Single Location or Posts Locator


jpequens comments:

Single Location. Phone number always shows up with the map and other items if you post using their shortcode. I assume the phone number is somehow saved in the database, I am looking to just grab it directly without all of the other unnecessary items.


jpequens comments:

https://forums.geomywp.com/topic/how-do-display-location-in-post/

This post also discusses it - but it is a bit dated. I think I need to create a loop and grab via an arg is my best guess.


jpequens comments:

Looking at php my admin it looks like geo my wordpress creates

gmw_locations - this contains all the locations by row with a field for 'address'
gmw_locatationmeta - this contains the phone number, website etc. and then pairs it to the gmw_locations row id.

I don't know database queries very well, but is there an easy way for me to call these?

2020-05-14

Mohamed Ahmed answers:

Hello Jpequens,

You can echo the shortcodes to be like that

-Address

<?php
echo "Address : " . do_shortcode( '[gmw_single_location object="post" elements="address"]' );
?>


-Full Address Details

<?php
echo "All Address Details: " . do_shortcode( '[gmw_single_location object="post" address_fields="city,postcode,region_name"]' );
?>


-Phone, Email or Website

<?php
echo "All Address Details: " . do_shortcode( '[gmw_single_location object="post" location_meta="phone,email,website"]' );
?>


If you need anything else, tell me


jpequens comments:

Same issues as the others. Phone always shows up with all the extra info, map etc.

I can isolate the map alone, and address alone, but never phone. And for address, it has a bunch of extra styling etc. that I would like to avoid if possible. Just trying to grab the raw data from the db if possible.


jpequens comments:

Looking at php my admin it looks like geo my wordpress creates

gmw_locations - this contains all the locations by row with a field for 'address'
gmw_locatationmeta - this contains the phone number, website etc. and then pairs it to the gmw_locations row id.

I don't know database queries very well, but is there an easy way for me to call these?

2020-05-14

Monit Jadhav answers:

From what I see you can echo out individual elements using the shortcode

[gmw_single_location object="post" elements="title,distance,map,address,directions_link"]


title,distance,map,address,directions_link these are the all the possible elements you can show individually wherever you want

For address you can the shortcode like below it will echo out entire address


<?php
echo "Address : " . do_shortcode( '[gmw_single_location object="post" elements="address"]' );
?>


For fields inside the Address element you can use the above shortcode


<?php
echo "Single Address entities: " . do_shortcode( '[gmw_single_location object="post" address_fields="city,postcode,region_name"]' );
?>

So for City you can do


<?php
echo "Single Address entities: " . do_shortcode( '[gmw_single_location object="post" address_fields="city"]' );
?>


For Phone numbers, they are stored as meta information so you need to use the shortcode below again you can echo multiple or single entities as you want

<?php
echo "Meta entities: " . do_shortcode( '[gmw_single_location object="post" location_meta="phone,email,website"]' );
?>


PHone number
<code>
<?php
echo "Meta entities: " . do_shortcode( '[gmw_single_location object="post" location_meta="phone"]' );
?>


Email:

<?php
echo "Meta entities: " . do_shortcode( '[gmw_single_location object="post" location_meta="email"]' );
?>


Website

<?php
echo "Meta entities: " . do_shortcode( '[gmw_single_location object="post" location_meta="website"]' );
?>


Detailed link here

https://docs.geomywp.com/article/163-single-location-shortcode


Let me know if you still have issues and I will be happy to help


jpequens comments:

Thanks for the help, and yes, I have tried all these and been through all of the docs. Phone number never shows up alone. It always shows up with the map etc.

I put it on the top of your pages using your code for phone only for you to see:

https://www.mygolfnotes.com/course/erie-shores/
<?php
echo "Meta entities phone only: " . do_shortcode( '[gmw_single_location object="post" location_meta="phone"]' );
?>

I assume when I save the address, phone, website whatever to the post it is saved in the db somewhere. I want to be able to grab it directly without the extra styling etc. of the shortcode


jpequens comments:

Looking at php my admin it looks like geo my wordpress creates

gmw_locations - this contains all the locations by row with a field for 'address'
gmw_locatationmeta - this contains the phone number, website etc. and then pairs it to the gmw_locations row id.

I don't know database queries very well, but is there an easy way for me to call these?