{"id":1253224,"date":"2017-03-13T04:26:32","date_gmt":"2017-03-13T11:26:32","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/"},"modified":"2017-03-14T14:22:58","modified_gmt":"2017-03-14T21:22:58","slug":"single-template-integrating-acf-custom-post-objects","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/","title":{"rendered":"Single Template integrating ACF Custom Post Objects"},"content":{"rendered":"<p>Hello,<\/p>\n<p>I&#8217;m trying to put an advanced custom field into the single-event template. I&#8217;ve used the same code on other custom post types and it work fine, I&#8217;ve also been able to add custom fields, but when I add a post object, it just displays the current events page info.<\/p>\n<p>Please see code below<\/p>\n<p>Thanks<br \/>\nWill<\/p>\n<p><code><br \/>\n&lt;?php<br \/>\n\/**<br \/>\n* Single Event Template<br \/>\n* A single event. This displays the event title, description, meta, and<br \/>\n* optionally, the Google map for the event.<br \/>\n*<br \/>\n* Override this template in your own theme by creating a file at [your-theme]\/tribe-events\/single-event.php<br \/>\n*<br \/>\n* @package TribeEventsCalendar<br \/>\n* @version 4.3<br \/>\n*<br \/>\n*\/<\/code><\/p>\n<p>if ( ! defined( &#8216;ABSPATH&#8217; ) ) {<br \/>\ndie( &#8216;-1&#8217; );<br \/>\n}<\/p>\n<p>$events_label_singular = tribe_get_event_label_singular();<br \/>\n$events_label_plural = tribe_get_event_label_plural();<\/p>\n<p>$event_id = get_the_ID();<\/p>\n<p>?&gt;<\/p>\n<p>&lt;div id=&#8221;tribe-events-content&#8221; class=&#8221;tribe-events-single&#8221;&gt;<br \/>\n&lt;?php while ( have_posts() ) : the_post(); ?&gt;<br \/>\n&lt;div id=&#8221;post-&lt;?php the_ID(); ?&gt;&#8221; &lt;?php post_class(); ?&gt;&gt;<br \/>\n&lt;!&#8211; Event featured image, but exclude link &#8211;&gt;<br \/>\n&lt;?php echo tribe_event_featured_image( $event_id, &#8216;full&#8217;, false ); ?&gt;<br \/>\n&lt;?php endwhile; ?&gt;<\/p>\n<p>&lt;div class=&#8221;eventsgallery&#8221;&gt;<br \/>\n&lt;?php $images = get_field(&#8216;attend_gallery&#8217;);<br \/>\nif( $images ): ?&gt;<br \/>\n&lt;div class=&#8221;gallery&#8221;&gt;<\/p>\n<ul>\n<ul>&lt;?php foreach( $images as $image ):<\/ul>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<ul>$content = &#8216;<\/p>\n<li>&#8216;;<br \/>\n$content .= &#8216;<a href=\"'. $image['url'] .'\">&#8216;;<br \/>\n$content .= &#8216;<img decoding=\"async\" src=\"'. $image['sizes']['thumbnail'] .'\" alt=\"'. $image['alt'] .'\" \/>&#8216;;<br \/>\n$content .= &#8216;<\/a>&#8216;;<br \/>\n\/\/add this to add captions to images (needs styling) $content .= &#8221;. $image[&#8216;caption&#8217;]. &#8216;<\/p>\n<p>&#8216;;<br \/>\n$content .= &#8216;<\/li>\n<\/ul>\n<\/ul>\n<p>&#8216;;<br \/>\nif ( function_exists(&#8216;slb_activate&#8217;) ){<br \/>\n$content = slb_activate($content);<br \/>\n}<\/p>\n<p>echo $content;?&gt;<br \/>\n&lt;?php endforeach; ?&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;?php endif; ?&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;div class=&#8221;clear&#8221;&gt;&lt;\/div&gt;<\/p>\n<p>&lt;?php tribe_the_notices() ?&gt;<br \/>\n&lt;?php the_title( &#8216;<\/p>\n<h2>&#8216;, &#8216;<\/h2>\n<p>&#8216; ); ?&gt;<br \/>\n&lt;?php while ( have_posts() ) : the_post(); ?&gt;<br \/>\n&lt;div id=&#8221;post-&lt;?php the_ID(); ?&gt;&#8221; &lt;?php post_class(); ?&gt;&gt;<br \/>\n&lt;!&#8211; Event content &#8211;&gt;<br \/>\n&lt;?php do_action( &#8216;tribe_events_single_event_before_the_content&#8217; ) ?&gt;<br \/>\n&lt;div class=&#8221;tribe-events-single-event-description tribe-events-content&#8221;&gt;<br \/>\n&lt;?php the_content(); ?&gt;<\/p>\n<p>&lt;div class=&#8221;tribe-events-schedule tribe-clearfix&#8221;&gt;<br \/>\n&lt;?php echo tribe_events_event_schedule_details( $event_id, &#8216;<\/p>\n<p>&#8216;, &#8216;<\/p>\n<p>&#8216; ); ?&gt;<br \/>\n&lt;?php if ( tribe_get_cost() ) : ?&gt;<br \/>\n&lt;span class=&#8221;tribe-events-cost&#8221;&gt;&lt;?php echo tribe_get_cost( null, true ) ?&gt;&lt;\/span&gt;&lt;br\/&gt;<br \/>\n<a>&#8221; target=&#8221;_blank&#8221;&gt;BOOK NOW<\/a><\/p>\n<p>&lt;?php endif; ?&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;?php endwhile; ?&gt;<br \/>\n&lt;div class=&#8221;clear&#8221;&gt;&lt;\/div&gt;<br \/>\n&lt;?php wp_reset_postdata(); ?&gt;<\/p>\n<p>&lt;?php<br \/>\n$post_objects = get_field(&#8216;similar_events&#8217;);<\/p>\n<p>if( $post_objects ): ?&gt;<\/p>\n<h2>Similar Events<\/h2>\n<p>&lt;div class=&#8221;featuredevents&#8221;&gt;<\/p>\n<p>&lt;?php foreach( $post_objects as $post): \/\/ variable must be called $post (IMPORTANT) ?&gt;<br \/>\n&lt;?php setup_postdata($post); ?&gt;<br \/>\n&lt;div class=&#8221;featuredeventsholder&#8221;&gt;<br \/>\n<a>&#8220;&gt;&lt;?php the_post_thumbnail(&#8216;square-large&#8217;); ?&gt;<\/a><br \/>\n&lt;div class=&#8221;featuredeventtitle&#8221;&gt;<br \/>\n<a>&#8220;&gt;<\/a><\/p>\n<h4>&lt;?php the_title(); ?&gt;<\/h4>\n<p>&lt;\/div&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;?php endforeach; ?&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;?php wp_reset_postdata(); \/\/ IMPORTANT &#8211; reset the $post object so the rest of the page works correctly ?&gt;<br \/>\n&lt;?php endif;?&gt;<\/p>\n<p>&lt;div class=&#8221;clear&#8221;&gt;&lt;\/div&gt;<\/p>\n<p>&lt;!&#8211; #tribe-events-footer &#8211;&gt;<\/p>\n<p>&lt;\/div&gt;&lt;!&#8211; #tribe-events-content &#8211;&gt;<br \/>\n&lt;?php get_footer(); ?&gt;<\/p>\n","protected":false},"template":"","class_list":["post-1253224","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>Single Template integrating ACF Custom Post Objects -<\/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\/single-template-integrating-acf-custom-post-objects\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Single Template integrating ACF Custom Post Objects -\" \/>\n<meta property=\"og:description\" content=\"Hello, I&#8217;m trying to put an advanced custom field into the single-event template. I&#8217;ve used the same code on other custom post types and it work fine, I&#8217;ve also been able to add custom fields, but when I add a post object, it just displays the current events page info. Please see code below Thanks [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/\" \/>\n<meta property=\"article:modified_time\" content=\"2017-03-14T21:22:58+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=\"3 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\/single-template-integrating-acf-custom-post-objects\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/\",\"name\":\"Single Template integrating ACF Custom Post Objects -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2017-03-13T11:26:32+00:00\",\"dateModified\":\"2017-03-14T21:22:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/#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\":\"Single Template integrating ACF Custom Post Objects\"}]},{\"@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":"Single Template integrating ACF Custom Post Objects -","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\/single-template-integrating-acf-custom-post-objects\/","og_locale":"en_US","og_type":"article","og_title":"Single Template integrating ACF Custom Post Objects -","og_description":"Hello, I&#8217;m trying to put an advanced custom field into the single-event template. I&#8217;ve used the same code on other custom post types and it work fine, I&#8217;ve also been able to add custom fields, but when I add a post object, it just displays the current events page info. Please see code below Thanks [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/","article_modified_time":"2017-03-14T21:22:58+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/","name":"Single Template integrating ACF Custom Post Objects -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2017-03-13T11:26:32+00:00","dateModified":"2017-03-14T21:22:58+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/single-template-integrating-acf-custom-post-objects\/#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":"Single Template integrating ACF Custom Post Objects"}]},{"@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\/1253224","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\/1253224\/revisions"}],"predecessor-version":[{"id":1254081,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1253224\/revisions\/1254081"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1253224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}