just for the link potion of the button I tried to use $website_title = tribe_events_get_event_website_title(); <?php echo $website; ?>
But this produces the text of the link then linked to itself. I cant use that in a <ahref>
So I need two custom fields, one for the button text and one for the button link and I need a way to drop that into the list view. Im thinking of editing the featured-image.php in my child theme and dropping the button in there.
I dont think there are filters/action hooks in the list view so documentation I found for adding fields to the event manager or venue wont work.
-
This reply was modified 3 years, 2 months ago by
davidjs.
This assumes you have the pro plugin. I do not know how to create custom files otherwise. You can paste this right into the template file you edit in the child theme or create a
new file for this and call it with a function.
———————————————-
Put this code in functions file
add_action( 'tribe_template_after_include:events/v2/list/event/featured-image',
function ( $file, $name, $template ) {
$template->template( 'list/event/tooltip-extra-fields' );
},
10,
3
);
————————————————————————————-
Put this code in featured-image.php for example or in its own file like tooltip-extra-fields.php
<?php
// Get the event ID.
$event_id = get_the_ID();
// Fetch from this Event all custom fields and their values.
$fields = tribe_get_custom_fields( $event_id );
?>
<div class=”theme-extra-event-fields”>
<?php if ( ! empty( $fields[‘Button Text’] ) ) : ?>
<h4>Artist</h4>
<p>
<?php if ( ! empty( $fields[‘Ticket Link’] ) ) : ?>
” target=”_blank”>
<?php endif; ?>
<?php echo esc_html( $fields[‘Button Text’] ); ?>
<?php if ( ! empty( $fields[‘Ticket Link’] ) ) : ?>
<?php endif; ?>
</p>
<?php endif; ?>
</div>
@davidjs
Thank you for sharing your solutions so that others can benefit from it!
While on that topic, just a small caveat, functions.php might not be the best cases in most cases. You can read about it here: https://wpmudev.com/blog/why-you-shouldnt-use-functions-php/
As a result, these days most people use a plugin such as the following instead:
- https://wordpress.org/plugins/my-custom-functions/
- https://wordpress.org/plugins/code-snippets/
Cheers,
Geoff