{"id":4022931,"date":"2013-08-12T23:32:38","date_gmt":"2013-08-12T23:32:38","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/location-custom-attributes\/"},"modified":"2016-08-21T03:52:45","modified_gmt":"2016-08-21T03:52:45","slug":"location-custom-attributes","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/location-custom-attributes\/","title":{"rendered":"Location Custom Attributes"},"content":{"rendered":"<p>I added some custom attributes to the Locations like Phone Number, emai and Facebook Page. I like to show them, but as they&#8217;re optional fields, first I have to check if the value is set.<br \/>\nI tried this code in functions.php file of my theme:<\/p>\n<pre><code>function filterLocationOutputCondition($replacement, $condition, $match, $EM_Location){\n    if( is_object($EM_Location) &amp;&amp; preg_match(&#039;\/^hay_telefonou\/&#039;,$condition, $matches) ){\n            \/* if ( !empty($EM_Location-&gt;location_region) ){ *\/\n        if( !in_array($args[&#039;Telefono Ubicacion&#039;],$EM_Location-&gt;location_attributes) &amp;&amp; !empty($EM_Location-&gt;location_attributes[&#039;Telefono Ubicacion&#039;])){\n                $replacement = preg_replace(&quot;\/\\{\\\/?$condition\\}\/&quot;, &#039;&#039;, $match);\n            }else{\n                $replacement = &#039;&#039;;\n            }\n        }\n        return $replacement;\n    }\nadd_action(&#039;em_location_output_condition&#039;, &#039;filterLocationOutputCondition&#039;, 1, 4);<\/code><\/pre>\n<p>Where &#8216;Telefono Ubicacion&#8217; means Location Phone<\/p>\n<p>The code in location template is the following:<\/p>\n<p><code>{hay_telefonou}&lt;strong&gt;TELEFONO:&lt;\/strong&gt;&lt;br&gt;#_ATT{Telefono Ubicacion}{\/hay_telefonou}<\/code><\/p>\n<p>The output can see in <a href=\"http:\/\/s410734030.onlinehome.us\/culturaslp.gob.mx\/ubicacion\/museo-del-ferrocarril-jesus-gacia-corona\/\">this page<\/a>.<\/p>\n<p>Hope someone can help me, and sorry for my bad english.<\/p>\n<p>https:\/\/wordpress.org\/plugins\/events-manager\/<\/p>\n","protected":false},"template":"","class_list":["post-4022931","topic","type-topic","status-closed","hentry","topic-tag-custom-fields"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4022931","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4022931\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=4022931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}