• Hi!
    May I ask for help?
    I want to insert from PHP some geographic lat,lng.
    I obserdeved table postmeta and tried to build string, but there are some problem…
    $map=’a:7:{s:3:”lat”;d:00.00;s:3:”lng”;d:00.00;s:4:”zoom”;i:15;s:7:”markers”;a:1:{i:0;a:4:{s:5:”label”;s:5:”pdusp”;s:13:”default_label”;s:0:””;s:3:”lat”;d:00.00;s:3:”lng”;d:00.00;}}s:7:”address”;s:5:”pdusp”;s:6:”layers”;a:1:{i:0;s:13:”OpenStreetMap”;}s:7:”version”;s:5:”1.1.9″;}

    $map=str_replace(‘s:3:”lat”;d:00.00′,’s:3:”lat”;d:’.str_replace(‘,’, ‘.’, $post->lat), $map);
    $map=str_replace(‘s:3:”lng”;d:00.00′,’s:3:”lng”;d:’.str_replace(‘,’, ‘.’, $post->lon), $map);
    update_field(‘map’,$map,$post_id);

    $wynik= $wpdb->update(
    ‘wp_postmeta’,
    array(
    ‘meta_value’ => $map
    ),
    array( ‘ID’ => $post_id,
    ‘meta_key’ =>’map’
    )
    );

  • The topic ‘Insert into postmeta lat,lng’ is closed to new replies.