Title: Location Custom Attributes
Last modified: August 21, 2016

---

# Location Custom Attributes

 *  Resolved [EliotNieto](https://wordpress.org/support/users/eliotnieto/)
 * (@eliotnieto)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/location-custom-attributes/)
 * I added some custom attributes to the Locations like Phone Number, emai and Facebook
   Page. I like to show them, but as they’re optional fields, first I have to check
   if the value is set.
    I tried this code in functions.php file of my theme:
 *     ```
       function filterLocationOutputCondition($replacement, $condition, $match, $EM_Location){
           if( is_object($EM_Location) && preg_match('/^hay_telefonou/',$condition, $matches) ){
                   /* if ( !empty($EM_Location->location_region) ){ */
               if( !in_array($args['Telefono Ubicacion'],$EM_Location->location_attributes) && !empty($EM_Location->location_attributes['Telefono Ubicacion'])){
                       $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
                   }else{
                       $replacement = '';
                   }
               }
               return $replacement;
           }
       add_action('em_location_output_condition', 'filterLocationOutputCondition', 1, 4);
       ```
   
 * Where ‘Telefono Ubicacion’ means Location Phone
 * The code in location template is the following:
 * `{hay_telefonou}<strong>TELEFONO:</strong><br>#_ATT{Telefono Ubicacion}{/hay_telefonou}`
 * The output can see in [this page](http://s410734030.onlinehome.us/culturaslp.gob.mx/ubicacion/museo-del-ferrocarril-jesus-gacia-corona/).
 * Hope someone can help me, and sorry for my bad english.
 * [http://wordpress.org/plugins/events-manager/](http://wordpress.org/plugins/events-manager/)

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

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/location-custom-attributes/#post-4023178)
 * here’s another thread which may help you with this – [http://wordpress.org/support/topic/conditional-has_region?replies=9](http://wordpress.org/support/topic/conditional-has_region?replies=9)
 *  Thread Starter [EliotNieto](https://wordpress.org/support/users/eliotnieto/)
 * (@eliotnieto)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/location-custom-attributes/#post-4023272)
 * Thanks for your answer, at first time, I’ve tried this solution, but it didn’t
   work. I think I’m doing something wrong. I changed the custom attribute UbicacionTel(
   without space) for doing easier.
    This is the code I added in the functions.hp
   file, (I highlighted the changes I’ve done in bold)
 *     ```
       add_action('em_location_output_condition', 'filterLocationOutputCondition', 1, 4);
           function filterLocationOutputCondition($replacement, $condition, $match, $EM_Location){
               if( is_object($EM_Location) && preg_match('/^<strong>hay_telefonou</strong>/',$condition, $matches) ){
                   if ( is_array($EM_Location-><strong>UbicacionTel</strong>) && !empty($EM_Location-><strong>UbicacionTel</strong>) ){
                       $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
                   }else{
                       $replacement = '';
                   }
               }
               return $replacement;
           }
       ```
   
 * But it doesn’t show anything.
    I also tried to show the attribute directly as`#
   _ATT{UbicacionTel}` but it doesn’t show correctly. Please, hope someone help 
   me and tell me what I’m doing wrong.
 *  Thread Starter [EliotNieto](https://wordpress.org/support/users/eliotnieto/)
 * (@eliotnieto)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/location-custom-attributes/#post-4023282)
 * In addition, I have the following attributes for the Locations in General Options
   page:
 * #_ATT{UbicacionFacebook}
    #_ATT{UbicacionEmail} #_ATT{UbicacionTel} #_ATT{UbicacionWeb}
 * The ‘Enable location attributes’ and ‘Enable location custom fields?’ options
   are checked YES, but when I add a new location, at the Attributes pane I get 
   the following message:
    ‘In order to use attributes, you must define some in 
   your templates, otherwise they’ll never show. Go to Events > Settings > General
   to add attribute placeholders.’
 * Is there any setting that I have missed?
    Thank you.
 *  [caimin_nwl](https://wordpress.org/support/users/caimin_nwl/)
 * (@caimin_nwl)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/location-custom-attributes/#post-4023299)
 * Have you added the custom attributes to _Events > Settings > General > Event 
   Attributes_?
 *  Thread Starter [EliotNieto](https://wordpress.org/support/users/eliotnieto/)
 * (@eliotnieto)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/location-custom-attributes/#post-4023313)
 * I added some custom attributes for the Events and other custom attributes for
   the Locations. But when I add a new Event, I see the custom attributes for the
   Events and the Locations. Example
 * _Events > Settings > General >_
 * **Custom attributes for events**
    #_ATT{E1} #_ATT{E2} #_ATT{E3}
 * **Custom attributes for locations**
    #_ATT{L1} #_ATT{L2} #_ATT{L3}
 * Adding a New Event:
 * Attributes Pane:
    —————- Attribute Name | Value E1: E2: E3: L1: L2: L3: —————
 * Add a new location:
 * Attributes Pane:
    —————- In order to use attributes, you must define some in 
   your templates…… —————
 * I don’t want to add location attributes for the events, so I don’t know what 
   I’m doing wrong.
 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/location-custom-attributes/#post-4023356)
 * for location, should something like #_LATT{L1} at Settings > General > Location
   Attributes
 *  Thread Starter [EliotNieto](https://wordpress.org/support/users/eliotnieto/)
 * (@eliotnieto)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/location-custom-attributes/#post-4023452)
 * Thank you!! I apologize for the inconveniences. That worked fine.. 🙂

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

 The topic ‘Location Custom Attributes’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.gif?rev=3711454)
 * [Events Manager - Calendar, Bookings, Tickets, Appointments and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)

 * 7 replies
 * 3 participants
 * Last reply from: [EliotNieto](https://wordpress.org/support/users/eliotnieto/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/location-custom-attributes/#post-4023452)
 * Status: resolved