{"id":943687,"date":"2015-02-19T08:17:48","date_gmt":"2015-02-19T16:17:48","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/"},"modified":"2015-03-30T08:18:30","modified_gmt":"2015-03-30T15:18:30","slug":"conditionally-display-additional-field-or-customize-additional-field-url","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/","title":{"rendered":"Conditionally display Additional Field, or customize Additional Field URL?"},"content":{"rendered":"<p>[Looked through previous related threads but couldn&#8217;t find an answer to my question.]<\/p>\n<p>I have a few Additional Fields in my events; they display in a custom-built Nivo Slider through WP_Query. <\/p>\n<p>The fields won&#8217;t always be used, and I&#8217;d only like them displayed when a value has been entered (e.g., there&#8217;s one for a Facebook link, one for a Buy Tickets link, etc.).<\/p>\n<p>I&#8217;d initially set the field as a &#8220;URL&#8221;. With a value of http:\/\/facebook.com, it outputs this HTML:<\/p>\n<p><code>&lt;a target=&quot;self&quot; href=&quot;http:\/\/facebook.com&quot;&gt;http:\/\/facebook.com&lt;\/a&gt;<\/code><\/p>\n<p>The good: If no value is entered, nothing is displayed. The bad is that it doesn&#8217;t allow me to style the link or add a class. I&#8217;d prefer an output of:<\/p>\n<p><code>http:\/\/facebook.com<\/code> <\/p>\n<p>&#8230; so I could wrap it in a <code>&lt;a&gt;<\/code> tag.<\/p>\n<p>So, I figured I&#8217;d just set the additional fields as Text. That gets me a plain value of <code>http:\/\/facebook.com<\/code> spit out. Here&#8217;s the code I&#8217;m using:<\/p>\n<p><code>&lt;a class=&quot;slider-facebook-link&quot; href=&quot;&lt;?php $additional_fields = tribe_get_custom_fields(); echo $additional_fields[&#039;Facebook Event Link&#039;];?&gt;&quot;&gt;Facebook&lt;\/a&gt;<\/code><\/p>\n<p>Is this the best way to achieve what I&#8217;d like? If so, how can I set a conditional to only display the field if it has a value?<\/p>\n<p>My attempt is:<\/p>\n<pre><code>&lt;?php if($additional_fields = tribe_get_custom_fields([&#039;Facebook Event Link&#039;])) { ?&gt;\n &lt;a class=&quot;slider-facebook-link&quot; href=&quot;&lt;?php $additional_fields = tribe_get_custom_fields(); echo $additional_fields[&#039;Facebook Event Link&#039;];?&gt;&quot;&gt;Facebook&lt;\/a&gt;\n&lt;?php } ?&gt;<\/code><\/pre>\n<p><a>&#8220;&gt;Facebook<\/a><\/p>\n","protected":false},"template":"","class_list":["post-943687","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>Conditionally display Additional Field, or customize Additional Field URL? -<\/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\/conditionally-display-additional-field-or-customize-additional-field-url\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Conditionally display Additional Field, or customize Additional Field URL? -\" \/>\n<meta property=\"og:description\" content=\"[Looked through previous related threads but couldn&#8217;t find an answer to my question.] I have a few Additional Fields in my events; they display in a custom-built Nivo Slider through WP_Query. The fields won&#8217;t always be used, and I&#8217;d only like them displayed when a value has been entered (e.g., there&#8217;s one for a Facebook [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/\" \/>\n<meta property=\"article:modified_time\" content=\"2015-03-30T15:18:30+00:00\" \/>\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=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/\",\"name\":\"Conditionally display Additional Field, or customize Additional Field URL? -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2015-02-19T16:17:48+00:00\",\"dateModified\":\"2015-03-30T15:18:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/#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\":\"Conditionally display Additional Field, or customize Additional Field URL?\"}]},{\"@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":"Conditionally display Additional Field, or customize Additional Field URL? -","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\/conditionally-display-additional-field-or-customize-additional-field-url\/","og_locale":"en_US","og_type":"article","og_title":"Conditionally display Additional Field, or customize Additional Field URL? -","og_description":"[Looked through previous related threads but couldn&#8217;t find an answer to my question.] I have a few Additional Fields in my events; they display in a custom-built Nivo Slider through WP_Query. The fields won&#8217;t always be used, and I&#8217;d only like them displayed when a value has been entered (e.g., there&#8217;s one for a Facebook [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/","article_modified_time":"2015-03-30T15:18:30+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/","name":"Conditionally display Additional Field, or customize Additional Field URL? -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2015-02-19T16:17:48+00:00","dateModified":"2015-03-30T15:18:30+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/conditionally-display-additional-field-or-customize-additional-field-url\/#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":"Conditionally display Additional Field, or customize Additional Field URL?"}]},{"@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\/943687","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":2,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/943687\/revisions"}],"predecessor-version":[{"id":943713,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/943687\/revisions\/943713"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=943687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}