Past events template
-
Hello,
I would like to create a new Event Brite template for my past events.
Would you please guide me for how to do this.
Thanks !
-
Hi Guillaume,
To get access to your past events, you’ll need to use
Eventbrite_Query
with thedisplay_private => true
parameter, like this:// Set up and call our Eventbrite query. $events = new Eventbrite_Query( apply_filters( 'eventbrite_query_args', array( 'display_private' => true, 'status' => 'all', ) ) );
Then you’ll have to handle the events that come back to display them as you wish.
Thanks,
But, before this, is it possible to create a new eventbrite template ?
(So I would have a WP page with only past events on it ?)
Anyone can help me with this ?
(How to create a new Evenbrite Template ?)
Hi Guillaume,
Yes, for sure, our templates are just normal page templates (they just happen to use
Eventbrite_Query
to get their “posts”). Create a normal page template in your theme and assign it to a page as you normally would, but use the code mentioned above to supply your Loop. Or, you can copy our existing template and modify it as you need.This article might also be helpful: https://themeshaper.com/2014/12/08/working-with-the-eventbrite-api-plugin/
So, I have to go to ‘/wp-content/plugins/eventbrite-api/tmpl’ and duplicate ‘eventbrite-index.php’.
I name the copy ‘eventbrite-archive.php’ and change the header for ‘* Template Name: Eventbrite Events Archives’ .
After this, I create a new page but in the template list, ‘Eventbrite Events Archives’ is not available…
Any idea why ?
THANKS !!
Or, maybe I just don’t understand where to put this code : ?
// Set up and call our Eventbrite query.
$events = new Eventbrite_Query( apply_filters( ‘eventbrite_query_args’, array(
‘display_private’ => true,
‘status’ => ‘all’,
) ) );Ah, it’ll be easier for you to put that new page template in your theme, so that it’s registered and handled properly for you. Because ours are in a plugin by necessity, we need to hack them in (which is why it isn’t automatically picking your new one up).
This info may be helpful too: https://developer.www.ads-software.com/themes/template-files-section/page-template-files/page-templates/
I’am almost here… I created a new template in my theme and pasted the content of the EventBrite Api template.
My new page now display my futur events.
In the new template, around line #17, I changed the code for :
// Set up and call our Eventbrite query. $events = new Eventbrite_Query( apply_filters( 'eventbrite_query_args', array( 'display_private' => true, 'status' => 'all', ) ) );
But the page still display my futur events only… Any idea how I can only display my past event instead ?
Have a look : https://www.catalethique.org/fr/evenements-passes/
Thanks !
Hm, that looks like it should work fine. You don’t have an
eventbrite_query_args
filter somewhere do you?..Can you paste the full template code in so I can see all of it?
The only one is the one from the code you gave me…
Please see the full template :
<?php /** * Template Name: Archives of EventBrite events */ get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <header class="page-header"> <h1 class="page-title"> <?php the_title(); ?> </h1> </header><!-- .page-header --> <?php // Set up and call our Eventbrite query. $events = new Eventbrite_Query( apply_filters( 'eventbrite_query_args', array( 'display_private' => true, 'status' => 'all', ) ) ); if ( $events->have_posts() ) : while ( $events->have_posts() ) : $events->the_post(); ?> <article id="event-<?php the_ID(); ?>" <?php post_class(); ?>> <header class="entry-header"> <?php the_post_thumbnail(); ?> <br /> <!--<p onclick="window.open('<?php echo get_permalink(); ?>')" >open</p> --> <?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?> <div class="entry-meta"> <?php eventbrite_event_meta(); ?> </div><!-- .entry-meta --> </header><!-- .entry-header --> <div class="entry-content"> <?php eventbrite_ticket_form_widget(); ?> </div><!-- .entry-content --> <footer class="entry-footer"> <?php eventbrite_edit_post_link( __( 'Edit', 'eventbrite_api' ), '<span class="edit-link">', '</span>' ); ?> </footer><!-- .entry-footer --> </article><!-- #post-## --> <?php endwhile; // Previous/next post navigation. eventbrite_paging_nav( $events ); else : // If no content, include the "No posts found" template. get_template_part( 'content', 'none' ); endif; // Return $post to its rightful owner. wp_reset_postdata(); ?> </main><!-- #main --> </div><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?>
Oh, you’re right, this was not properly supported as it was.
It’s been added to a new update, v1.0.11 – just update the plugin and it will work now as expected.
Note that the above will give you all of your events; it will still be up to you to sort through them somehow. I’d suggest looking at the
eventbrite_api_call_response
filter, which would allow you to remove any events that are live (if you want it to be only past events). Filtering at that point, right at the API call, will mean that paging and such will all work properly at the template.Closing; just open a new thread if you’re still having issues.
- The topic ‘Past events template’ is closed to new replies.