{"id":1174286,"date":"2016-10-09T11:10:12","date_gmt":"2016-10-09T18:10:12","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/"},"modified":"2016-10-09T11:10:12","modified_gmt":"2016-10-09T18:10:12","slug":"custom-fields-formatting-url-without-changing-the-type-to-text","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/","title":{"rendered":"Custom fields: formatting URL without changing the type to &quot;text&quot;"},"content":{"rendered":"<p>Unfortunately I haven&#8217;t found a solution in the forum, although I found a lot of similar posts, but those solutions didn&#8217;t solve my problem.<\/p>\n<p>I have a custom field named &#8220;Anmeldung&#8221; and it&#8217;s type is &#8220;URL&#8221; &#8211; I use this custom field to add an URL to an external registration page.<\/p>\n<p>I found out, that custom fields with type = url have already the a href included &#8211; so as a result my URL that was entered will show up as:<br \/>\n<code>&lt;a href=&quot;https:\/\/external-website-for-registration.com&quot; target=&quot;_blank&quot;&gt;https:\/\/external-website-for-registration.com &lt;\/a&gt;<\/code><\/p>\n<p>that means the name of the link == URL :-\/<\/p>\n<p>What I tried to figure out was to get the Link like:<\/p>\n<p><code>&lt;a href=&quot;https:\/\/external-website-for-registration.com&quot; target=&quot;_blank&quot;&gt;Whatever I want to name the link&lt;\/a&gt;<\/code><\/p>\n<p>I found a post in the forum where it is recommended to change the type from URL to text to be able to modify it. That works nearly as expected \ud83d\ude09<\/p>\n<pre><code>$custom_fields = tribe_get_custom_fields(); \n$anmeldung_url = $custom_fields[ &#039;Anmeldung&#039; ];\n\necho &quot;&lt;strong&gt;Anmeldung&lt;\/strong&gt;&lt;br \/&gt;&lt;a href=&#039;$anmeldung_url&#039; target=&#039;_blank&#039;&gt;zur Anmeldung&lt;\/a&gt;&quot;;<\/code><\/pre>\n<p>Therefore I had to identify the specific custom_field (thank you, I also found some solutions in your forum to do this :-)) and I could build my link as preferred.<\/p>\n<p>BUT&#8230;<\/p>\n<p>Due to the fact that all custom fields are selected and displayed using the foreach loop I could not figure out how to &#8220;interrupt&#8221; this to modify the specific URL field.<\/p>\n<pre><code>&lt;?php foreach ( $fields as $name =&gt; $value ): ?&gt;\n\t\t\t\t&lt;dt&gt; &lt;?php echo esc_html( $name );  ?&gt; &lt;\/dt&gt;\n\t\t\t\t&lt;dd class=&quot;tribe-meta-value&quot;&gt;\n\t\t\t\t\t&lt;?php\n\t\t\t\t\t\/\/ This can hold HTML. The values are cleansed upstream\n\t\t\t\t\techo $value;\n\t\t\t\t\t?&gt;\t\t\t\t\t\n\t\t\t\t&lt;\/dd&gt;\n\t\t\t&lt;?php endforeach ?&gt;<\/code><\/pre>\n<p>I either have to accept that the URL will be listed twice (from the foreach part and afterwards from my specific request) or delete the foreach part and select each custom field separately.<\/p>\n<p>I wonder if there isn&#8217;t a better solution to directly resolve this problem with the foreach loop? Because a second problem came up in case that I request each custom field separately &#8211; I couldn&#8217;t figute out how to get the Label.<\/p>\n<p>In my solution I just entered the text in front of my echo, but this seem to be a bad solution, with reference to any changes that could be made.<\/p>\n<p>Is there a way to  get the custom field labels, too?<\/p>\n<p>Many thanks in advance for your support!<br \/>\nDinah<\/p>\n","protected":false},"template":"","class_list":["post-1174286","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Custom fields: formatting URL without changing the type to &quot;text&quot; -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Custom fields: formatting URL without changing the type to &quot;text&quot; -\" \/>\n<meta property=\"og:description\" content=\"Unfortunately I haven&#8217;t found a solution in the forum, although I found a lot of similar posts, but those solutions didn&#8217;t solve my problem. I have a custom field named &#8220;Anmeldung&#8221; and it&#8217;s type is &#8220;URL&#8221; &#8211; I use this custom field to add an URL to an external registration page. I found out, that [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/\",\"name\":\"Custom fields: formatting URL without changing the type to &quot;text&quot; -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2016-10-09T18:10:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Calendar Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Events Calendar PRO\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Custom fields: formatting URL without changing the type to &quot;text&quot;\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Custom fields: formatting URL without changing the type to &quot;text&quot; -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/","og_locale":"en_US","og_type":"article","og_title":"Custom fields: formatting URL without changing the type to &quot;text&quot; -","og_description":"Unfortunately I haven&#8217;t found a solution in the forum, although I found a lot of similar posts, but those solutions didn&#8217;t solve my problem. I have a custom field named &#8220;Anmeldung&#8221; and it&#8217;s type is &#8220;URL&#8221; &#8211; I use this custom field to add an URL to an external registration page. I found out, that [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/","name":"Custom fields: formatting URL without changing the type to &quot;text&quot; -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2016-10-09T18:10:12+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-fields-formatting-url-without-changing-the-type-to-text\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Calendar Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/"},{"@type":"ListItem","position":4,"name":"Events Calendar PRO","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/"},{"@type":"ListItem","position":5,"name":"Custom fields: formatting URL without changing the type to &quot;text&quot;"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1174286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1174286\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1174286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}