WordPress.org

Ready to get started?Download WordPress

Forums

Pronamic Google Maps
[resolved] frontend address input for real estate postings? (4 posts)

  1. qzha017
    Member
    Posted 1 year ago #

    Hi there this plugin looks more comprehensive and tailor-able than all the others. But I am novice at php codes and desperately in need of help.

    1.)Can I place this pronmaic google map in a specific location in my template, i.e., in the loop just after the posts content (single view) like how I would add other stuffs such as post view counts etc. so I will need to put in the php code like below?

    <?php
    
    if(function_exists('pronamic_google_maps')) {
        pronamic_google_maps(array(
            'width' => 290 ,
            'height' => 200
        ));
    }
    
    ?>

    2.)The map location and markup of that post would be from location data authors in-putted when they wrote the post from frontend.

    I am setting up a site that allow users post their properties for rent or sale, so when they input their property address the address will be sent to the map to show the location in single view. Can this be done? Say I will create a custom input field for “address” and then hook this data to the google map? how can I do this?

    Thank you so much I really need this function and don’t know how to achieve it.

    http://wordpress.org/extend/plugins/pronamic-google-maps/

  2. wombat86
    Member
    Posted 1 year ago #

    I would like to know how to do #2 also, generate a map from custom address fields that the user submits from the front end.

    thank you!

  3. Remco Tolsma
    Member
    Plugin Author

    Posted 1 year ago #

    Can I place this pronmaic google map in a specific location in my template, i.e., in the loop just after the posts content (single view) like how I would add other stuffs such as post view counts etc. so I will need to put in the php code like below?

    Yes, that is correct.

    The map location and markup of that post would be from location data authors in-putted when they wrote the post from frontend.

    I am setting up a site that allow users post their properties for rent or sale, so when they input their property address the address will be sent to the map to show the location in single view. Can this be done? Say I will create a custom input field for “address” and then hook this data to the google map? how can I do this?

    This is not very easy beceause the address has to be geocoded. If you use the 'save_post' action to store the address you could achieve this.

    function prefix_save_post( $post_id ) {
      $address = filter_input( INPUT_POST, 'address', FILTER_SANITIZE_STRING );
    
      update_post_meta( $post_id, '_pronamic_google_maps_address', $address );
      update_post_meta( $post_id, '_pronamic_google_maps_active', true );
    }
    
    add_action( 'save_post', 'prefix_save_post' );
    
    // Create post object
    $my_post = array(
      'post_title'    => 'My post',
      'post_content'  => 'This is my post.',
      'post_status'   => 'publish',
      'post_author'   => 1,
      'post_category' => array(8,39)
    );
    
    // Insert the post into the database
    wp_insert_post( $my_post );

    I didn't test the code above, but this should work. The Pronamic Google Maps plugin should geocode the address automatically.

    If you however don't have a lot of experience with PHP and WordPress this might be too difficult.

  4. captjones
    Member
    Posted 1 year ago #

    hey, could you explain the stuff above?

    i am familiar with custom fields and minimal php.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic