I have a [map] shortcode in my sidebar.php file to display a google map.
<?php echo do_shortcode(' [map address="123 Main Street"] '); ?>
That works fine, but what I want to do is put a <?php in the address area, because I want it to automatically populate using the address fields I have created.
<?php echo do_shortcode(' [map address="<?php stripslashes($options['address_city']); ?>"] '); ?>
[address_city] is a field located in the admin panel, so my clients to enter their details. The code for this can be found in mytheme/functions/theme_admin.php and looks like this;
<h3><?php _e( 'City' ); ?></h3> <input id="complete_theme_settings[address_city]" class="regular-text" type="text" name="complete_theme_settings[address_city]" value="<?php esc_attr_e( $options['address_city'] ); ?>" /> <p>
Thanks for your help!
- The topic ‘Using PHP in Google map shortcode to get address’ is closed to new replies.