creating an anchor
-
How can I add an anchor to link to this map?
//custom field lat lon GOOGLE MAPS function my_map_shortcode() { $latitude = get_post_meta(get_the_ID(), 'latitude', true); $longitude = get_post_meta(get_the_ID(), 'longitude', true); if (empty($latitude) || empty($longitude)) { return ''; } $map_url = 'https://www.google.com/maps/embed/v1/place?key=AIzaSyAQGd95X0YBBzcLX4NwMeXEiCIjUy6dO4I&zoom=15&q=' . $latitude . ',' . $longitude ; return '<br></br>Posizione su mappa<br></br><iframe width="100%" height="450" frameborder="0" style="border:0" src="' . $map_url . '" allowfullscreen></iframe><br></br>'; } add_shortcode('my_map', 'my_map_shortcode'); function my_add_map_to_post_content($content) { if (is_singular('post')) { $map = do_shortcode('[my_map]'); $content .= $map; } return $content; } add_filter('the_content', 'my_add_map_to_post_content'); function my_add_meta_box() { add_meta_box('my_location', 'Posizione', 'my_location_callback', 'post', 'normal', 'default'); } add_action('add_meta_boxes', 'my_add_meta_box'); function my_location_callback($post) { wp_nonce_field(basename(__FILE__), 'my_location_nonce'); $latitude = get_post_meta($post->ID, 'latitude', true); $longitude = get_post_meta($post->ID, 'longitude', true); ?> <p> <label for="latitude">Latitudine</label> <br /> <input type="text" name="latitude" id="latitude" value="<?php echo esc_attr($latitude); ?>" /> </p> <p> <label for="longitude">Longitudine</label> <br /> <input type="text" name="longitude" id="longitude" value="<?php echo esc_attr($longitude); ?>" /> </p> <?php } function my_save_location_meta($post_id) { if (!isset($_POST['my_location_nonce']) || !wp_verify_nonce($_POST['my_location_nonce'], basename(__FILE__))) { return; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if (!current_user_can('edit_post', $post_id)) { return; } if (isset($_POST['latitude'])) { update_post_meta($post_id, 'latitude', sanitize_text_field($_POST['latitude'])); } if (isset($_POST['longitude'])) { update_post_meta($post_id, 'longitude', sanitize_text_field($_POST['longitude'])); } } add_action('save_post', 'my_save_location_meta');
I’d like to put an icon on this page: https://test.sacconicase.com/case-vacanza/lignano-sabbiadoro-appartamenti-vacanze/ , I click the icon and I go direclty to the map here in this page: https://test.sacconicase.com/lignano-sabbiadoro-appartamento-7-persone-vicino-al-mare/
The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘creating an anchor’ is closed to new replies.