Support

Account

Home Forums Front-end Issues google maps field front end show only address

Solving

google maps field front end show only address

  • hi, want create a list directory, for every post i want add a location , now if use the custom field of google maps , the output is this:

    LOT 1 Lobethal Road, Uraidla SA 5142, Australia, -34.947489682220045, 138.74999977648258

    how hide the cordinates longitudes and latitudes and show only the address example this :

    “”LOT 1 Lobethal Road, Uraidla SA 5142, Australia””

    the name of my field is “mapx” : <?php the_field(‘mapx’); ?>

    ??

    thanks

  • 
    $map_location = get_field( 'mapx' );
    echo $map_location['address'];
    
  • thanks with your code have solved , but have a other question:

    how show only state zip code and city ?

    example this ” Uraidla SA 5142, Australia”

    thanks

  • Hi,

    You could explode the string and var_dump the result to find the index to echo, for example:

    $address = explode( ', ', $map_location['address'] );
    var_dump( $address );
    echo $address[1] . ' ' . $address[2];

    But I would save that info in a seperate field to keep it consistent.
    Hope it helps!

  • hey scheurta

    i would like to get help if you can 🙂

    this is my code
    <?php
    // The Query
    $user_query = new WP_User_Query( array( ‘role’ => ‘Dj’ ) );
    $map_location = get_field( ‘map_pin’ );
    echo $map_location[‘address’];
    // User Loop
    if ( ! empty( $user_query->results ) ) {
    foreach ( $user_query->results as $user ) {
    echo ‘<p>’ . $user->display_name . ‘</p>’;
    echo ‘<p>’ . $user->$map_location[‘address’] . ‘</p>’;

    }
    } else {
    echo ‘No users found.’;
    }
    ?>

    the code is showing the display name of the users and i am trying to show all the addresses of those users but some how the code that you wrote here does not work at the code that i wrote.

    can you please help with this?

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘google maps field front end show only address’ is closed to new replies.