Duplicate Organizers Meta Section With Different Header
Upon re-reading my topic, I just want to clarify the goal noted in my first paragraph.
Speakers and Organizers don’t necessarily have to be differentiated on the backend, per se, just available to be selected under two different meta sections/headers. Ideally, they pull from the same custom “Organizers” post type that comes with The Events Calendar out of the box.
Thanks for reaching out!
This could technically be done, but it is a bit outside the scope of support that we are able to offer here in the forums. If you’d like to give it a shot, our themer’s guide has some good info on customizing our plugins. To start, you might want to take a look at the following:
We also have a list of recommended developers that you could contact if you would like to have the code done for you.
I’m sorry I don’t have a better answer for you at the moment, but I hope this helps get you started!
Hmm..is it really that complicated? I was hoping that it would be as simple as being pointed to the necessary portion of the template file (details.php and /modules/organizers.php) that I could duplicate and change the header output on the frontend.
What about Advanced Custom Fields? Going this route, would I use the relational “Post Object” field type, or something else? I was able to get the meta field to display on the backend (and even select from the organizers custom post type), but can you or anyone else direct me toward a decent tutorial on how to get ACF relational field data to display in the meta event details section of the single event view? My attempt at adding get_field(‘organizersonly’) resulted in “empty” despite having selected organizers on the backend.
Technically adding custom fields to the tribe_events post type is not too complicated (either with ACF or PHP), but getting them to work on the front end form is a bit trickier. I can point you towards the files that we use for that form, and you can definitely give it a shot!
Community Events edit form:
Templates for organizer fields:
I’d also recommend taking a look at wp-content/plugins/the-events-calendar-community-events/src/views/community/src/Tribe/Main.php line 1999 for guidance on saving the field when the form is submitted.
We do not currently have any tutorials on displaying ACF fields on events pages, but you would want to customize the template for that section of the single events page:
ACF has some really good documentation on displaying these fields, so I would recommend taking a look at that.
I hope this helps get you started!
Thank you so much for the comprehensive response! The effort you guys put in for support is peerless. Unfortunately, I may not have been clear:
I am strictly attempting to add this meta section to the Events Calendar Pro single event view — I am not working with the Community Events add-on at all.
That said, I’m diving into the ACF documentation now. Still, ideally I find a way to achieve this via PHP and without forcing myself to rely on the potentially variable compatibility of another another plugin.
I’ll keep you posted in regard to any progress! Thanks so much.
Is there any chance you could tell me why this is only outputting “array” on the frontend (attempting to use ACF)? As you can see, I basically copied the Organizer template. I then added the call to grab the template to meta.php
<?php /** * Single Event Meta (Organizer) Template * * Override this template in your own theme by creating a file at: * [your-theme]/tribe-events/modules/meta/organizer.php * * @package TribeEventsCalendar * @version 4.4 */ $organizer_ids = tribe_get_organizer_ids(); $multiple = count( $organizer_ids ) > 1; $phone = tribe_get_organizer_phone(); $email = tribe_get_organizer_email(); $website = tribe_get_organizer_website_link(); ?> <div class="tribe-events-meta-group tribe-events-meta-group-organizer"> <h3 class="tribe-events-single-section-title"><?php echo "Organizers"; ?></h3> <dl> <?php do_action( 'tribe_events_single_meta_organizer_section_start' ); /* * Get a field object and display it with it's value */ $field_name = "onlyorganizer"; $field = get_field_object($value); $value = get_field( "onlyorganizer" ); echo $value['label'] . get_field( "onlyorganizer") . $field['value']; do_action( 'tribe_events_single_meta_organizer_section_end' ); ?> </dl> </div>
Here is the exported php of the field group via ACF:
if( function_exists('acf_add_local_field_group') ): acf_add_local_field_group(array( 'key' => 'group_5a26fec4071a0', 'title' => 'speaker organizer', 'fields' => array( array( 'key' => 'field_5a26ff1a9337b', 'label' => 'onlyorganizer', 'name' => 'onlyorganizer', 'type' => 'post_object', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'post_type' => array( 0 => 'tribe_organizer', ), 'taxonomy' => array( ), 'allow_null' => 1, 'multiple' => 1, 'return_format' => 'object', 'ui' => 1, ), ), 'location' => array( array( array( 'param' => 'post_type', 'operator' => '==', 'value' => 'tribe_events', ), ), array( array( 'param' => 'post_type', 'operator' => '==', 'value' => 'tribe_organizer', ), ), ), 'menu_order' => 0, 'position' => 'normal', 'style' => 'default', 'label_placement' => 'top', 'instruction_placement' => 'label', 'hide_on_screen' => '', 'active' => 1, 'description' => '', )); endif;
I created a new template file from scratch and tried again. Still just outputting “Array” with this template file coding:
<?php $field_name = "the_organizers"; $field = get_field_object($field_name); ?> <div class="tribe-events-meta-group tribe-events-meta-group-organizer"> <h3 class="tribe-events-single-section-title"><?php echo "Organizers"; ?></h3> <dl> <?php do_action( 'tribe_events_single_meta_organizer_section_start' ); echo $field; do_action( 'tribe_events_single_meta_organizer_section_end' ); ?> </dl> </div>
Screenshot attached as well.
Got it. If it’s of any use to you or anyone else, here is the working code:
<?php /** * Single Event Meta (Organizer) Template * * Override this template in your own theme by creating a file at: * [your-theme]/tribe-events/modules/meta/organizer.php * * @package TribeEventsCalendar * @version 4.4 */ ?> <div class="tribe-events-meta-group tribe-events-meta-group-organizer"> <h3 class="tribe-events-single-section-title"><?php echo "Organizers"; ?></h3> <dl> <?php $posts = get_field('the_organizers');?> <?php foreach( $posts as $p ): // variable must NOT be called $post (IMPORTANT) ?> <dt style="display:none;"><?php // This element is just to make sure we have a valid HTML ?></dt> <dd class="tribe-organizer"> <a href="<?php echo get_permalink( $p->ID ); ?>"><?php echo get_the_title( $p->ID ); ?></a> <?php the_field('author', $p->ID); ?> </dd> <?php endforeach; ?> <?php do_action( 'tribe_events_single_meta_organizer_section_end' ); ?> </dl> </div>
I’m glad to hear you were able to get this working, and thanks so much for sharing your code here! I’m sure it will be helpful to other users looking for something similar.
Since this has been marked “resolved”, I’ll go ahead and close it out. Please feel free to open up a new thread if you have any other questions!
The topic ‘Duplicate Organizers Meta Section With Different Header’ is closed to new replies.