-
fjvanittersum
I have a similar problem. I am evaluating The Event Calendar on my test system and tried to make a GPP Page Hero for a single event. I made a Page Hero, (Block Element, Page Hero, hook before_content, priority 10). I could select the category (events) in the selection area. Above the single event a white space appears, but not the Page Hero with a featured image and a title. The same block does work on regular posts.
TEC posts have a title and a featured image in the wp-posts database. TEC ha a template overriding system that can be place in the wp-content/themes/generatepress/tribe folder (or in a child-theme).
There is a single-event.php file:
<?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.6.19 * */ if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } $events_label_singular = tribe_get_event_label_singular(); $events_label_plural = tribe_get_event_label_plural(); $event_id = Tribe__Events__Main::postIdHelper( get_the_ID() ); /** * Allows filtering of the event ID. * * @since 6.0.1 * * @param int $event_id */ $event_id = apply_filters( 'tec_events_single_event_id', $event_id ); /** * Allows filtering of the single event template title classes. * * @since 5.8.0 * * @param array $title_classes List of classes to create the class string from. * @param string $event_id The ID of the displayed event. */ $title_classes = apply_filters( 'tribe_events_single_event_title_classes', [ 'tribe-events-single-event-title' ], $event_id ); $title_classes = implode( ' ', tribe_get_classes( $title_classes ) ); /** * Allows filtering of the single event template title before HTML. * * @since 5.8.0 * * @param string $before HTML string to display before the title text. * @param string $event_id The ID of the displayed event. */ $before = apply_filters( 'tribe_events_single_event_title_html_before', '<h1 class="' . $title_classes . '">', $event_id ); /** * Allows filtering of the single event template title after HTML. * * @since 5.8.0 * * @param string $after HTML string to display after the title text. * @param string $event_id The ID of the displayed event. */ $after = apply_filters( 'tribe_events_single_event_title_html_after', '</h1>', $event_id ); /** * Allows filtering of the single event template title HTML. * * @since 5.8.0 * * @param string $after HTML string to display. Return an empty string to not display the title. * @param string $event_id The ID of the displayed event. */ $title = apply_filters( 'tribe_events_single_event_title_html', the_title( $before, $after, false ), $event_id ); $cost = tribe_get_formatted_cost( $event_id ); ?> <div id="tribe-events-content" class="tribe-events-single"> <p class="tribe-events-back"> <a href="<?php echo esc_url( tribe_get_events_link() ); ?>"> <?php printf( '« ' . esc_html_x( 'All %s', '%s Events plural label', 'the-events-calendar' ), $events_label_plural ); ?></a> </p> <!-- Notices --> <?php tribe_the_notices() ?> <?php echo $title; ?> <div class="tribe-events-schedule tribe-clearfix"> <?php echo tribe_events_event_schedule_details( $event_id, '<h2>', '</h2>' ); ?> <?php if ( ! empty( $cost ) ) : ?> <span class="tribe-events-cost"><?php echo esc_html( $cost ) ?></span> <?php endif; ?> </div> <!-- Event header --> <div id="tribe-events-header" <?php tribe_events_the_header_attributes() ?>> <!-- Navigation --> <nav class="tribe-events-nav-pagination" aria-label="<?php printf( esc_html__( '%s Navigation', 'the-events-calendar' ), $events_label_singular ); ?>"> <ul class="tribe-events-sub-nav"> <li class="tribe-events-nav-previous"><?php tribe_the_prev_event_link( '<span>«</span> %title%' ) ?></li> <li class="tribe-events-nav-next"><?php tribe_the_next_event_link( '%title% <span>»</span>' ) ?></li> </ul> <!-- .tribe-events-sub-nav --> </nav> </div> <!-- #tribe-events-header --> <?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 ); ?> <!-- 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> <!-- .tribe-events-single-event-description --> <?php do_action( 'tribe_events_single_event_after_the_content' ) ?> <!-- Event meta --> <?php do_action( 'tribe_events_single_event_before_the_meta' ) ?> <?php tribe_get_template_part( 'modules/meta' ); ?> <?php do_action( 'tribe_events_single_event_after_the_meta' ) ?> </div> <!-- #post-x --> <?php if ( get_post_type() == Tribe__Events__Main::POSTTYPE && tribe_get_option( 'showComments', false ) ) comments_template() ?> <?php endwhile; ?> <!-- Event footer --> <div id="tribe-events-footer"> <!-- Navigation --> <nav class="tribe-events-nav-pagination" aria-label="<?php printf( esc_html__( '%s Navigation', 'the-events-calendar' ), $events_label_singular ); ?>"> <ul class="tribe-events-sub-nav"> <li class="tribe-events-nav-previous"><?php tribe_the_prev_event_link( '<span>«</span> %title%' ) ?></li> <li class="tribe-events-nav-next"><?php tribe_the_next_event_link( '%title% <span>»</span>' ) ?></li> </ul> <!-- .tribe-events-sub-nav --> </nav> </div> <!-- #tribe-events-footer --> </div><!-- #tribe-events-content -->
A single event has 7 templates: back-link, title, content, footer, notices, recurring-description, comments). Their content is rather limited. The title template is:
<?php the_title( '<h1 class="tribe-events-single-event-title">', '</h1>' );
The back-link-template (which is above the title):
<?php $label = esc_html_x( 'All %s', '%s Events plural label', 'the-events-calendar' ); $events_label_plural = tribe_get_event_label_plural(); ?> <p class="tribe-events-back"> <a href="<?php echo esc_url( tribe_get_events_link() ); ?>"> « <?php printf( $label, $events_label_plural ); ?> </a> </p>
Content-template:
<?php $event_id = $this->get( 'post_id' ); ?> <div id="post-<?php echo absint( $event_id ); ?>" <?php post_class(); ?>> <?php tribe_the_content( null, false, $event_id ); ?> </div>
Is this info OK?
Is there a way getting the GPP Page Hero working on a single event of the Event Calendar?
Thanks !
Frans
-
Hi there,
i split your reply to a new topic , as the other topic was related to replacing the entire TEC Content. Whereas a page hero should just work, as it gets hooked in after the header.
Can i see the issue on your site ?
As this topic is now your own, you can use the Private Information field to share any URLs etc.
-
fjvanittersum
Thanks David,
Unfortunately, the page is not visible: I am developing the plugin on a locally installed system (WAMP).
Could the problem be that the Page Header block hooks into wp-content/themes/generatepress/single.php whereas a TEC post uses wp-content/plugins/the-events-calendar/src/views/single-event or single-event-blocks ?
Or is this not correct?
Thanks !
Frans
-
The default hook for the Block Element – Page Hero is the
generate_after_header
hook. Which is in the themesheader.php
template.Is the themes site header present on the TEC page ?
-
fjvanittersum
Two comments:
1) There is a heading section, defined in wp-content/plugins/the-events-calendar/src/views/v2/components/header.php:<?php use \Tribe\Events\Views\V2\Template; /** * View Component: Header * * Override this template in your own theme by creating a file at: * [your-theme]/tribe/events/v2/components/header.php * * See more documentation about our views templating system. * * @link http://evnt.is/1aiy * * @version 6.2.0 * @since 6.2.0 * * @var Template $this Template Engine instance rendering. * @var bool $disable_event_search Boolean on whether to disable the event search. */ $header_classes = [ 'tribe-events-header' ]; if ( empty( $disable_event_search ) ) { $header_classes[] = 'tribe-events-header--has-event-search'; } ?> <header <?php tribe_classes( $header_classes ); ?>> <?php $this->template( 'components/messages' ); ?> <?php $this->template( 'components/messages', [ 'classes' => [ 'tribe-events-header__messages--mobile' ] ] ); ?> <?php $this->template( 'components/header-title' ); ?> <?php $this->template( 'components/breadcrumbs' ); ?> <?php $this->template( 'components/events-bar' ); ?> <?php $this->template( 'components/content-title' ); ?> <?php $this->template( [ $this->get_view_slug(), 'top-bar' ] ); ?> </header>
2) It appears the the GPP Page Hero Blocks are inserted, but that the dynamic data are not loaded. This is the page source information from the single-event page (I have added a few comments):
`<!– I think this is the part of the Page Hero the does not show the defined post header – Frans –>
<div class=”site grid-container container hfeed” id=”page”>
<div class=”site-content” id=”content”><div class=”content-area” id=”primary”>
<main class=”site-main” id=”main”><article id=”post-0″ class=”post-0 page type-page status-publish” itemtype=”https://schema.org/CreativeWork” itemscope>
<div class=”inside-article”>
<div class=”gb-container gb-container-3f30c0b6″>
<div class=”gb-container gb-container-54415e5f”>
<div class=”gb-container gb-container-a8d6f6eb”></div>
</div>
</div><!– Here starts the TEC html (Frans) –>
<div class=”entry-content” itemprop=”text”>
<section id=”tribe-events”><div class=”tribe-events-before-html”></div><span class=”tribe-events-ajax-loading”><img class=”tribe-events-spinner-medium” src=”http://127.0.0.1/willibrordusorgel/wp-content/plugins/the-events-calendar/src/resources/images/tribe-loading.gif” alt=”Laden Evenementen” /></span>
<div id=”tribe-events-content” class=”tribe-events-single tribe-blocks-editor”><p class=”tribe-events-back”>
<a href=”http://127.0.0.1/willibrordusorgel/events/”>
« Alle Evenementen </a>
</p><!– This is the title of the post –>
<h1 class=”tribe-events-single-event-title”>Hector Olivera</h1>I hope this information is helpful
Thanks !
Frans
-
Fernando
Hi Frans,
I see. Can you install a plugin like “Show Current Template”?: https://wordpress.org/plugins/show-current-template/
Then, view a Single Event Page, and confirm whether or not the Header file of GP is being loaded.
Example using the said plugin to check the templates used: https://share.getcloudapp.com/NQu5z2yK
-
Ivan Oung
Hi Frans,
Just came here to say that I found peace with my problem.
Inspired by an SEO YouTube channel, an easier way to do this might be just by using redirects.
Redirect all native TEC plugin events to the new page with GPblocks, and use noindex to prevent Google from crawling duplicate content.
The more that I use TEC the more that I hated it, so I’m actually looking for alternatives atm. What other event calendar plugins have you tried?
Best,
Ivan -
fjvanittersum
Thanks! I installed the “Show current template plugin”. This is the result:
Relatief pad voor template: themes/generatepress/page.php Thema naam:GeneratePress (GEEN sub-thema) Onderstaande templatebestanden zijn ook opgenomen: themes\generatepress\content-page.php themes\generatepress\footer.php themes\generatepress\functions.php themes\generatepress\header.php themes\generatepress\inc\block-editor.php themes\generatepress\inc\class-css.php themes\generatepress\inc\class-html-attributes.php themes\generatepress\inc\class-rest.php themes\generatepress\inc\class-theme-update.php themes\generatepress\inc\class-typography-migration.php themes\generatepress\inc\class-typography.php themes\generatepress\inc\css-output.php themes\generatepress\inc\customizer.php themes\generatepress\inc\defaults.php themes\generatepress\inc\deprecated.php themes\generatepress\inc\general.php themes\generatepress\inc\markup.php themes\generatepress\inc\plugin-compat.php themes\generatepress\inc\structure\archives.php themes\generatepress\inc\structure\comments.php themes\generatepress\inc\structure\featured-images.php themes\generatepress\inc\structure\footer.php themes\generatepress\inc\structure\header.php themes\generatepress\inc\structure\navigation.php themes\generatepress\inc\structure\post-meta.php themes\generatepress\inc\structure\search-modal.php themes\generatepress\inc\structure\sidebars.php themes\generatepress\inc\theme-functions.php themes\generatepress\inc\typography.php themes\generatepress\page.php themes\generatepress\sidebar.php
Does it provide a clue?
Thanks!
Frans
-
fjvanittersum
The main reason for me to evaluate TEC was the additional dates. I do no have multiple venues etc. Maybe there is an alternative solution without TEC using GPP and GenerateBlocks:
add custom fields for event date and times
Show the custom fields with event date and time in a QueryLoop of GB
Sort the QueryLoop blocks on the date custom field.I think it is possible to sort on a custom field in GB: https://docs.generateblocks.com/article/order-query-loop-by-custom-field/
@fernando: might this be an alternative solution?
I have to figure out how to add custom fields (dates) in WP or GPP.
Frans
-
Fernando
I see. You’re Single Event Page is using the GP header.php template it seems. So, the Page Hero should be working. If you can share admin login credentials through the Private Information field, we can take a closer look at the issue for you.
As for your other inquiry, yes, custom fields can be used to order Query Loop Blocks. With regard to this being an alternative for you, that would depend on the structure you want and your development skill level as well.
If it is an alternative you’re looking at, you’ll need a CPT plugin to create your own “events”: https://wordpress.org/plugins/custom-post-type-ui/
You’ll also need a plugin like ACF to add custom fields: https://www.advancedcustomfields.com/resources/getting-started-with-acf/
-
Ivan Oung
@fernando you no longer need a CPT for creating CPTs, ACF takes care of everything for you, from creating custom post types to creating custom fields!
-
Fernando
Oh yes, you’re right, Ivan! Thank you!
-
fjvanittersum
Can GenerateBlocks sort on custom fields in a query loop block? E.g. on a custom date field?
And show custom fields in QueryLoop blocks?Than my problems are solved using ACF and GenerateBlocks without an Event plugin.
Frans
-
Hi Frans,
Check this article:https://docs.generateblocks.com/article/order-query-loop-by-custom-field/
-
fjvanittersum
Thanks! I’ll wil try this code the upcoming weeks.
I have another question. I made a date custom field (daum_evenement, j F Y format). In some views I would like to present the year or the day or month. I made a hook element in GPP (generate_after_entry_title) and can add the custom field with:
<?php the_field('datum_evenement'); ?>
It generates the full date.
In order to get only the year of the date, I tried in the same hook:
<?php substr(the_field('datum_evenement'), 0,4); ?> <?php date("Y", the_field('datum_evenement')); ?>
Both solutions do not work: always the full date is given.
Is there another solution? Other php-code in the hook ?
Thanks !
Frans
-
Fernando
Hi Frans,
Can you try this:
<?php $dateString = get_field('datum_evenement'); // Replace this with your date string $timestamp = strtotime($dateString); if($dateString){ $year = date('Y', $timestamp); // Extract the year echo $year; } ?>
Let us know how it goes.
- You must be logged in to reply to this topic.