Title: phpcode inside your shortcode, for automatic city update
Last modified: August 2, 2017

---

# phpcode inside your shortcode, for automatic city update

 *  [vinay404](https://wordpress.org/support/users/vinay404/)
 * (@vinay404)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/phpcode-inside-your-shortcode-for-automatic-city-update/)
 * Hi,
    I have a real estate portal in which i have city, I have displayed city 
   info on property page, and now i want to add weather information below that page
   in template file. so on every property page it gets property city and display
   that cities weather conditions.
 * I was able to produce the city outside with code but it shows the city at front
   end but not working if i add inside your shortcode. and if i manualy insert city
   then its displaying fine. but i need to automate this to property city, how can
   i do that. I am using below codes in my theme. here is the link of my website.
   you can see any property page.
 * [http://www.krieta.com](http://www.krieta.com)
 * code i am using :
 *     ```
       <?php
       /**
        * Created by PhpStorm.
        * User: waqasriaz
        * Date: 21/01/16
        * Time: 7:17 PM
        */
       global $post_meta_data;
       $city = houzez_taxonomy_simple('property_city');
       $google_map_address = get_post_meta( get_the_ID(), 'fave_property_map_address', true );
       $google_map_address_url = "http://maps.google.com/?q=".$google_map_address;
       if( !empty($city) ) {
   
       ?>
       <div id="city" class="detail-city detail-block target-block">
       <div class="detail-title">
       		<h2 class="title-left"><?php esc_html_e( 'About City', 'houzez' ); ?></h2>
       		<?php if( !empty($google_map_address) ) { ?>
       		<div class="title-right">
       			<a target="_blank" href="<?php echo esc_url($google_map_address_url); ?>"><?php esc_html_e( 'Open on Google Maps', 'houzez' ); ?> <i class="fa fa-map-marker"></i></a>
       		</div>
       		<?php } ?>
       </div>
       		<div>
       		<h4 class="title-left"><?php
               	$terms = get_the_terms( $post->ID , 'property_city' ); 
                       foreach ( $terms as $term ) {
                       $term_link = get_term_link( $term, 'property_city' );
                       if( is_wp_error( $term_link ) )
                        continue;
                       echo '<a href="' . $term_link . '">' . $term->name . '</a>';
                       } 
   
       			?>
   
       		</h4>
       		</div>
   
       		<div><?php echo term_description( $term, 'property_city' ) ?></div>
               <div><?php echo do_shortcode( '[awesome-weather location=”<?php echo $term->name ?>” locale=”in”]' ); ?></div>
               <?php echo $term->name ?>, IN
       <?php } ?>
       </div>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [vinay404](https://wordpress.org/support/users/vinay404/)
 * (@vinay404)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/phpcode-inside-your-shortcode-for-automatic-city-update/#post-9374460)
 * Hi, I shorted it out it started working by doing a simple edit in code. whil 
   copying your shortcode from this site it copied something wrong.Earlier it was:
 * `[awesome-weather location=”<?php echo $term->name ?>” locale=”in”]``
 * But it should be like this:
    `[awesome-weather location="<?php echo $term->name?
   >" locale=”in”]`
 * If look closer you will find the diffrence in both code.
 * I have posted it for someone might get in this kind of problem.
    Thanks regards.
 *  Thread Starter [vinay404](https://wordpress.org/support/users/vinay404/)
 * (@vinay404)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/phpcode-inside-your-shortcode-for-automatic-city-update/#post-9374653)
 * hey its nt working its showing default city to everypage timberlake park. please
   help
 *  Thread Starter [vinay404](https://wordpress.org/support/users/vinay404/)
 * (@vinay404)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/phpcode-inside-your-shortcode-for-automatic-city-update/#post-9382448)
 * Can anyone please reply me ?
 *  Thread Starter [vinay404](https://wordpress.org/support/users/vinay404/)
 * (@vinay404)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/phpcode-inside-your-shortcode-for-automatic-city-update/#post-9385643)
 * ok, i am uninstalling tghe plugin, thanks.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘phpcode inside your shortcode, for automatic city update’ is closed to
new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/awesome-weather_ad7c7d.svg)
 * [Awesome Weather Widget](https://wordpress.org/plugins/awesome-weather/)
 * [Support Threads](https://wordpress.org/support/plugin/awesome-weather/)
 * [Active Topics](https://wordpress.org/support/plugin/awesome-weather/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/awesome-weather/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/awesome-weather/reviews/)

 * 4 replies
 * 1 participant
 * Last reply from: [vinay404](https://wordpress.org/support/users/vinay404/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/phpcode-inside-your-shortcode-for-automatic-city-update/#post-9385643)
 * Status: not resolved