{"id":1086821,"date":"2016-03-09T12:33:06","date_gmt":"2016-03-09T20:33:06","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-to-get-custom-meta-field-from-a-recurring-event\/"},"modified":"2016-03-11T13:48:46","modified_gmt":"2016-03-11T21:48:46","slug":"how-to-get-custom-meta-field-from-a-recurring-event","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-to-get-custom-meta-field-from-a-recurring-event\/","title":{"rendered":"How to get custom meta field from a recurring event?"},"content":{"rendered":"<p>I am having some trouble trying to get the value of a custom meta field from a recurring event. Bear with me as I lay out the whole problem.<\/p>\n<p>I am making a page template that will list out a week&#8217;s worth of upcoming events. Here&#8217;s the &#8220;query&#8221; I&#8217;m working with:<\/p>\n<pre><code>$args = array(\n\t&#039;start_date&#039; =&gt; $start_date-&gt;format(&#039;Y-m-d&#039;),\n\t&#039;end_date&#039; =&gt; $end_date-&gt;format(&#039;Y-m-d&#039;),\n);\n$events = tribe_get_events($args);<\/code><\/pre>\n<p><em>$start_date<\/em> is previously set up to be today&#8217;s date, and <em>$end_date<\/em> is set up to be 1 week after that. The foreach loop works fine with setup_postdata() and all, in that I can loop through a week&#8217;s events and retrieve basic post info like title, permalink, and excerpt.<\/p>\n<p><strong>However for recurring events I cannot get values from custom meta fields.<\/strong> This only happens if the event post was created <em>after<\/em> the meta field was created.<\/p>\n<p>I&#8217;m using Advanced Custom Fields to set up the meta fields, &#8220;admission&#8221; and &#8220;events_tickets_url&#8221;. We set up a bunch of dummy events to work with while developing the site, and since then I added these two meta fields, meaning the posts were created before the meta fields. One of the recurring events is titled &#8220;HIGHLIGHTS TOUR&#8221;, where I used the &#8220;Edit All&#8221; link to update those two meta fields to &#8220;free with admission&#8221; and &#8220;https:\/\/google.com&#8221; respectively.<\/p>\n<p>Then I can look through the individual instances of that event and the fields, and they do show that they have been updated. Like I can go to today&#8217;s instance of &#8220;HIGHLIGHTS TOUR&#8221; and the &#8220;events_tickets_url&#8221; field shows as &#8220;https:\/\/google.com&#8221;.<\/p>\n<p>The crazy thing is though that in the foreach loop, get_field(&#8216;events_tickets_url&#8217;) returns NULL as if the meta field doesn&#8217;t even exist. Even passing in the post ID of the current event in the loop to get_field() doesn&#8217;t work. It seems like whatever post ID I get from the post objects in the loop just isn&#8217;t the right ID to use in order to get a meta field. Or does the calendar plugin filter into get_the_ID() to return a different ID than normal?<\/p>\n<p>In any case, I don&#8217;t really know what&#8217;s going on here. The only solution I have found is to create a new version of the event post, now that the meta fields already exist. But there&#8217;s gotta be a better way? What is the reason why I can&#8217;t get meta field values (at least from ACF) from recurring events, if the meta fields were created after the event posts?<\/p>\n<p>In the screenshots I provided, the first shows one of the events being output during the foreach loop. These are meant to show that the meta field return as NULL during the loop, but if I edit the posts there is a value in that field.<\/p>\n","protected":false},"template":"","class_list":["post-1086821","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>How to get custom meta field from a recurring event? -<\/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\/how-to-get-custom-meta-field-from-a-recurring-event\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to get custom meta field from a recurring event? -\" \/>\n<meta property=\"og:description\" content=\"I am having some trouble trying to get the value of a custom meta field from a recurring event. Bear with me as I lay out the whole problem. I am making a page template that will list out a week&#8217;s worth of upcoming events. Here&#8217;s the &#8220;query&#8221; I&#8217;m working with: $args = array( &#039;start_date&#039; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-to-get-custom-meta-field-from-a-recurring-event\/\" \/>\n<meta property=\"article:modified_time\" content=\"2016-03-11T21:48:46+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=\"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\/how-to-get-custom-meta-field-from-a-recurring-event\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-to-get-custom-meta-field-from-a-recurring-event\/\",\"name\":\"How to get custom meta field from a recurring event? -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2016-03-09T20:33:06+00:00\",\"dateModified\":\"2016-03-11T21:48:46+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-to-get-custom-meta-field-from-a-recurring-event\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-to-get-custom-meta-field-from-a-recurring-event\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-to-get-custom-meta-field-from-a-recurring-event\/#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\":\"How to get custom meta field from a recurring event?\"}]},{\"@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":"How to get custom meta field from a recurring event? -","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\/how-to-get-custom-meta-field-from-a-recurring-event\/","og_locale":"en_US","og_type":"article","og_title":"How to get custom meta field from a recurring event? -","og_description":"I am having some trouble trying to get the value of a custom meta field from a recurring event. Bear with me as I lay out the whole problem. I am making a page template that will list out a week&#8217;s worth of upcoming events. Here&#8217;s the &#8220;query&#8221; I&#8217;m working with: $args = array( &#039;start_date&#039; [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-to-get-custom-meta-field-from-a-recurring-event\/","article_modified_time":"2016-03-11T21:48:46+00:00","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\/how-to-get-custom-meta-field-from-a-recurring-event\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-to-get-custom-meta-field-from-a-recurring-event\/","name":"How to get custom meta field from a recurring event? -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2016-03-09T20:33:06+00:00","dateModified":"2016-03-11T21:48:46+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-to-get-custom-meta-field-from-a-recurring-event\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-to-get-custom-meta-field-from-a-recurring-event\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-to-get-custom-meta-field-from-a-recurring-event\/#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":"How to get custom meta field from a recurring event?"}]},{"@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\/1086821","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":1,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1086821\/revisions"}],"predecessor-version":[{"id":1086830,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1086821\/revisions\/1086830"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1086821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}