Home › Forums › Calendar Products › Events Calendar PRO › Single Template integrating ACF Custom Post Objects
- This topic has 3 replies, 1 voice, and was last updated 9 years, 1 month ago by
Will.
-
AuthorPosts
-
March 13, 2017 at 4:26 am #1253224
Will
ParticipantHello,
I’m trying to put an advanced custom field into the single-event template. I’ve used the same code on other custom post types and it work fine, I’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
Will
<?php
/**
* Single Event Template
* A single event. This displays the event title, description, meta, and
* optionally, the Google map for the event.
*
* Override this template in your own theme by creating a file at [your-theme]/tribe-events/single-event.php
*
* @package TribeEventsCalendar
* @version 4.3
*
*/if ( ! defined( ‘ABSPATH’ ) ) {
die( ‘-1’ );
}$events_label_singular = tribe_get_event_label_singular();
$events_label_plural = tribe_get_event_label_plural();$event_id = get_the_ID();
?>
<div id=”tribe-events-content” class=”tribe-events-single”>
<?php while ( have_posts() ) : the_post(); ?>
<div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<!– Event featured image, but exclude link –>
<?php echo tribe_event_featured_image( $event_id, ‘full’, false ); ?>
<?php endwhile; ?><div class=”eventsgallery”>
<?php $images = get_field(‘attend_gallery’);
if( $images ): ?>
<div class=”gallery”>- <?php foreach( $images as $image ):
- $content = ‘
- ‘;
$content .= ‘‘;
$content .= ‘‘;
$content .= ‘‘;
//add this to add captions to images (needs styling) $content .= ”. $image[‘caption’]. ‘‘;
$content .= ‘
‘;
if ( function_exists(‘slb_activate’) ){
$content = slb_activate($content);
}echo $content;?>
<?php endforeach; ?></div>
<?php endif; ?>
</div>
<div class=”clear”></div><?php tribe_the_notices() ?>
<?php the_title( ‘‘, ‘
‘ ); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<!– Event content –>
<?php do_action( ‘tribe_events_single_event_before_the_content’ ) ?>
<div class=”tribe-events-single-event-description tribe-events-content”>
<?php the_content(); ?><div class=”tribe-events-schedule tribe-clearfix”>
<?php echo tribe_events_event_schedule_details( $event_id, ‘‘, ‘
‘ ); ?>
<?php if ( tribe_get_cost() ) : ?>
<span class=”tribe-events-cost”><?php echo tribe_get_cost( null, true ) ?></span><br/>
” target=”_blank”>BOOK NOW<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
<div class=”clear”></div>
<?php wp_reset_postdata(); ?><?php
$post_objects = get_field(‘similar_events’);if( $post_objects ): ?>
Similar Events
<div class=”featuredevents”>
<?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<div class=”featuredeventsholder”>
“><?php the_post_thumbnail(‘square-large’); ?>
<div class=”featuredeventtitle”>
“><?php the_title(); ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php wp_reset_postdata(); // IMPORTANT – reset the $post object so the rest of the page works correctly ?>
<?php endif;?><div class=”clear”></div>
<!– #tribe-events-footer –>
</div><!– #tribe-events-content –>
<?php get_footer(); ?>March 14, 2017 at 2:23 pm #1254082Trisha
MemberHi Will!
Sorry to hear your running into trouble! I did a few quick tests on my end and ran into the same issue with the post object field.
My suggestion would be to utilize one of the available action hooks to attach a custom function to.
do_action( 'tribe_events_single_event_before_the_content' )looks like a good candidate based on where you currently have the code.Let me know if I can help any further or if you have any other questions.
Cheers,
TrishaApril 5, 2017 at 9:35 am #1265116Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team - ‘;
-
AuthorPosts
- The topic ‘Single Template integrating ACF Custom Post Objects’ is closed to new replies.
