Need Google Maps on Classifieds

Hello,

I've installed and configured Google Maps. It works great on posts and pages, but I cannot seem to get maps to show on my classified ads.

I installed the geolocation plug as recommended to use custom fields to interact with the map.

Perhaps I misunderstood. Does it need to be manually placed. From the Google Maps Settings it appears that adding a "Address" custom field and "latitude" and "longitude" should automatically create and place a map.

Also, on the Google Maps widget -how do i specify only Classified ads to show. Do I use the Query. What is the correct procedure?

Best
Aaron

  • Kimberly
    • Champion of Loops

    Aaron,

    Thanks for using the WPMU forums, I hope you are enjoying your membership :slight_smile:

    Let's get a little more clarification on your map issue: are you able to create a map at all? Does it show on the back end only? Not showing on the front?

    From what I saw with the geolocation plugin it should automatically generate the map. I am not sure how the geolocation plugin is supposed to integrate into the front end, I would imagine it would be automatic.

    As for the widget, yep, using a query is your best route. :slight_smile: You can find more details here:
    https://premium.wpmudev.org/project/wordpress-google-maps-plugin/installation/

    Best,

    Kimberly

  • Aaron
    • Site Builder, Child of Zeus

    The maps are working on the front end - they just will not appear on the Classified Posts automatically. Any idea how to make this work? It doesn't seem the query will work if the map is not functional automatically

  • Kimberly
    • Champion of Loops

    Ok, I get what you're asking! Sorry :slight_smile:

    It's the intended behavior of the plugin to show in the back end as a shortcode.

    You can see the full process here in the Installation Instructions specifically referenced in step 10 I believe.

    The map is functional when it is created just not viewable in the post editor. If it were then it wouldn't be a google map it would be a simple jpg or similar with no relative data. And then it definitely wouldn't be query-able. :slight_smile:
    ,
    Does this help?

    Best,

    Kimberly


    If this thread is not resolved because the suggested action did not work or you have any more questions related to this thread, please feel free to post them below including any new symptoms or errors and tick the 'Mark as Not Resolved (re-open)' box below the post area (or else we'll miss it!)

  • Aaron
    • Site Builder, Child of Zeus

    Hello Kimberly,

    II understand how the maps work with short codes on the post editor.
    As I mentioned they are working great except I cannot get them on the classified posts -automatically -. Perhaps I am misunderstanding the Google Map section - but it seems they are to appear automatically so long as the proper custom fields are present. Here is an excerpt from the Google Map settings:

    Map custom fields
    My posts have latitude/longitude fields
    Latitude field name: latitude
    Logitude field name:longitude
    My posts have an address field
    Address field name: address
    When these fields are found, I want to
    (A new map will be automatically created, using the defaults you specified above)
    Associate the new map to post: Yes No
    Automatically show the map: Yes No
    If previous option is set to "Yes", the new map will be shown

    I have included address and latitude & longitude custom fields to the classified settings. Still there is no map that show in short code or on the front end.

    Best
    Aaron

  • Kimberly
    • Champion of Loops

    Aaron,

    Ok I see where you're going

    I have included address and latitude & longitude custom fields to the classified settings

    How did you create these fields? If you used custompress you will need to be sure you associate them with the post_type.

  • Aaron
    • Site Builder, Child of Zeus

    Hi Kimberly,

    I have done this before using other plug in's and yes this is absolutely true. I included a pasted section of the settings to demonstrate how I had done this. I understand you must go through the basics because in most cases simple over sights cause issues. At this point I feel we need to look deeper.

    This is the central issue from the start. I believe everything is done right. I read everything, have experience doing this type of setup using other plug ins as well as other CMS platforms.

    Can I get some help figuring out why the maps are not automatically being created on my Classifieds Posts using the Google Maps plug In? I am using the Studio theme on a Multi Site Buddy Press install.

    Best
    Aaron

  • Aaron
    • Site Builder, Child of Zeus

    Hi Kimberley,

    I reread the Custom Press section again. This is the only thing I can see as the problem:

    Do I need to put the embed code for the new custom fields in the in the loop? The fields are appearing, but I have not put the embed code in the loop for the new custom fields.

    If so, Could you tell me the path or plug in that will allow insertion into the loop? I'm a bit confused on this. Could this be why the map is not showing? I did not add embed code for the new custom field types into the loop.

    Best
    Aaron

  • Vladislav
    • Dead Eye Dev

    Hello,

    Can we please first determine if it's the case of maps not being auto-generated at all with the data from your custom fields, or if the maps are actually generated, but simply not shown? Could you please check the map list interface in the post editor to see if there are any new maps that correspond to locations you entered in the custom fields?

    Also, another point is that the maps will be generated using the data from latitude/longitude pair, OR the address field. If all of them are present, latitude/longitude pair will take precedence over the address field. Could it be perhaps possible that the data in your latitude/longitude pair is somehow corrupt?

  • Aaron
    • Site Builder, Child of Zeus

    Hello,

    By "map list interface in the post editor" - Do you mean the shortcode that will show on the back end of the Classified section (equivalent to the post editor) If so, nothing is showing at all. If not, where is the map list interface and post editor?

    The address field has an address but the latitude/longitude sections are empty. Many plug ins auto fill the latitude and longitude once the address is entered. This is not the case here - they remain empty even when and address is entered. Perhaps this is normal behavior?

    Best
    Aaron

  • Vladislav
    • Dead Eye Dev

    Hi,

    You can get a list of all maps on your site when you click the little globe icon right above your post editor: http://i55.tinypic.com/30sfyg3.png Your auto-created maps should be listed as well in the pop-up that appears.

    As for latitude/longitude fields, the plugin doesn't write anything to your custom fields, it just reads from them. So, if you're not actually using the latitude/longitude fields, you don't really need them. Also, since the auto-mapping works by calling Google geolocating service in the background, can you please make sure that the addresses you enter in the address fields are existing and valid?

  • Aaron
    • Site Builder, Child of Zeus

    Hello,

    Just checked and there are no maps listed on the little globe map icon. The address is definitely a valid address. Also - I tried several addresses on several test listings.

    I am able to manually add the map on the classified listings - it works great. With the amount of listings we will have - it is not practical to manually add each map.

    Any idea why the address custom field would not be read. It was created as a text box (multi line) and the addresses are being entered in standard format: 547 Baltic Way, San Jose, CA 95111 also it works entering manually - so it is mostly working. Just need it done automatically.

    Best
    Aaron

  • Kimberly
    • Champion of Loops

    Aaron,

    I'm referencing an earlier comment from Ve:
    Also, another point is that the maps will be generated using the data from latitude/longitude pair, OR the address field. If all of them are present, latitude/longitude pair will take precedence over the address field.

    Do you still have lat and long present?

  • Aaron
    • Site Builder, Child of Zeus

    Hi Kimberly,

    I renamed the Latitude and Longitude (I could not delete them -?)

    Also, I removed them as named fields in Google Map settings. Now only the "address" custom field remain.

    I then created a new post with a good address - still no automatic map.

    Any more suggestions?

    Best
    Aaron

  • Kimberly
    • Champion of Loops

    Aaron,

    have you considered running the repair?

    It may need to completely erase the lat long custom fields from the tables?

    You will need to delete the lat and long custom fields from custom press and remove the embed code from your template file if you want to remove them from the editor.

  • Aaron
    • Site Builder, Child of Zeus

    Hi Kimberly,

    I set it up initially without the Latitude or Longitude fields. It did not work - so I added the Latitude and Longitude. I did run the repair last week in an effort to resolve this - no dice.

    I re-named the Latitude and Longitude field (could not delete - ?). Today I again ran the repair to fix missing tables and the BuddyPress rebuild. Maps working perfectly on Buddypress. Nothing on Classified Listngs unless I add them manually. :slight_frown:

    I never added the embed code to the loop- this is for the template only right? It looked fine so I did not bother. Could this be the issue? The other Custom fields work fine.

    Any other suggestions? We really need this fixed as we are about to launch the site soon. This is actually one of the last hold ups. I'm running 70 plus of the WPMUdev plug in's - all work great so far except this map issue. I have a feeling it is a simple fix - we just need to find it.

    Best
    Aaron

  • fitoussi
    • The Incredible Code Injector

    @desibizbuy,
    i believe (i might be wrong) that the custom fields created by the classifieds's plugin custom fields cause the problem.
    first, when you create a custom field name with classifieds "address" is kind of a "generic" name. the actual name that Wordpress takes into account is the field ID of this custom field. Moreover, in order to create a map another custom field named "agm_map_created" need to be created automatically and that is where the map ID of this post is being created and this is how it is being display. this field cannot be created using the classifieds plugin. what i believe you should do is "turn on" the wordpress custom fileds. you can do it by adding this line:

    <?php
    add_post_type_support( 'classifieds', 'custom-fields' ) ;
    ?>

    to functions.php file. now you are going to see wordpress custom fields just below the classifieds custom fields. create custom field name "address" and add an address to it. once you will save the post you will see the "agm_map_created" custom fields created automatically and it will hold the map id. this i think will solve your issue.

  • Kimberly
    • Champion of Loops

    Ve: as per your earlier question

    Can we please first determine if it's the case of maps not being auto-generated at all with the data from your custom fields, or if the maps are actually generated, but simply not shown?

    Looks like it's the former, maps are not being genrated

  • Aaron
    • Site Builder, Child of Zeus

    Hello,

    I added this to the function.php for my theme (studio) as follows:

    <?php
    add_post_type_support( 'classifieds', 'custom-fields' ) ;
    ?>

    Also tried placing it at the beginning with the other :"add" commands. This did not create a "Wordpress Custom Field" field option in my Classifieds Content Types section. Maybe I'm looking in the wrong place?

    I tried placing it at the end - still no field. Is this the correct functions.php file? Perhaps I have it in the wrong place?
    I see a wdca_custom_ad Post Type. I switched the content type to this setting for "Address" -tried it and created and ad. Still no map appears.

    Seems like we are close to the solution. Could you give me a bit more guidance please?

    Thanks
    Aaron

  • Aaron
    • Site Builder, Child of Zeus

    Hello,

    I see the Custome Fields section (same fields I created under 'classifieds') I see Excerpt and Author below the "Custom Fields" section. The Addreess field is gone (because I changed it to "wdca_custom_ad" probably. I changed it back to "classifieds" and it reappeared.

    But still - this will get me back where I started it seems. Did I add this code to the correct function.php in my theme folder?

    Also, the goal is to allow members to add the address in the front end and have the map automatically created. Is this what will happen once it is working properly?

    Best
    Aaron

  • fitoussi
    • The Incredible Code Injector

    if the studio theme is the one you are using (not a child theme) so yes, it should go in its function.php. i would just take the line of code and insert it just below the closing

    ?>

    of your functions.php with no space.
    then in the "new classified page" in the admin area you should see custom fields like in the screenshot below. this is how it is in my site.
    once we realize that this is actually the issue and i am not wrong (hopefully i am not) and let you work for nothing. then we could add a little function that will take the address from the classifieds custom field and add it to wordpress customfields when the user press the "save ad" button.

  • fitoussi
    • The Incredible Code Injector

    desibizbuy,
    forget about the functions.php and try this simple thing.
    take the filed ID of your address custom field from classifieds. should look something like "text_4f70e444bab0d". add "_ct_" to the beginning of it it so it will be "_ct_text_4f70e444bab0d".
    take this field and put it in the google map plugin where the address field should be.
    see if it works.

  • Aaron
    • Site Builder, Child of Zeus

    Hello,

    Still no Custom Field section as you show on yuor screen. I do have a Custom Field section -but it is composed of all the different custom fields I created for Real Estate Listings (which what we are using Classifieds for)

    Here is where I placed the new code. I am demonstrating bot places I put it
    1. at the end befor the Update Notification.
    2. at the end before the Update Notification.

    </div>

    <?php
    add_post_type_support( 'classifieds', 'custom-fields' ) ;
    ?>
    </div>
    <?php

    }
    }
    endif;
    ///////////////////////////////////////////////////////////////////////////
    /* -------------------- Update Notifications Notice -------------------- */
    if ( !function_exists( 'wdp_un_check' ) ) {
    add_action( 'admin_notices', 'wdp_un_check', 5 );
    add_action( 'network_admin_notices', 'wdp_un_check', 5 );
    function wdp_un_check() {
    if ( !class_exists( 'WPMUDEV_Update_Notifications' ) && current_user_can( 'edit_users' ) )
    echo '<div class="error fade"><p>' . __('Please install the latest version of our free Update Notifications plugin which helps you stay up-to-date with the most stable, secure versions of WPMU DEV themes and plugins. More information »', 'wpmudev') . '</p></div>';
    }
    }
    /* --------------------------------------------------------------------- */
    <?php
    add_post_type_support( 'classifieds', 'custom-fields' ) ;
    ?>
    ?>

    Neither resulted in a new custom field as you show on you png.

    Hmmmm what now?

    Best
    Aaron

  • fitoussi
    • The Incredible Code Injector

    your welcome.
    that was the first thing i tried but without the _ct_(didnt know about it) . just now running through the code i found out that in order to display the custom field i need to add _ct_. could saved lot of time if i knew it before.

  • fitoussi
    • The Incredible Code Injector

    No need special coding Johnny.
    In classifieds Take the field ID that hold the address. For example "text-blah" add "_ct_" at the beginning of it so you'll have "_ct_text-blah". Take this and add it in google maps settings where is the " address field name" field. check "yes" for "use custom post meta field support". Check "yes" for both "associate new map to post" and "automatically show map".
    That is it.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.