Below, you’ll find a detailed guide on how to add the Import Eventbrite Events Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Import Eventbrite Events Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Import Eventbrite Events Plugin and the shortcodes it provides:
"Import Eventbrite Events is a powerful WordPress plugin that allows users to seamlessly import and manage their Eventbrite events directly from their WordPress dashboard."
- [eventbrite_events]
Import Eventbrite Events [eventbrite_events] Shortcode
The Import Eventbrite Events plugin shortcode allows you to display a list of Eventbrite events on your WordPress site. It provides options to customize the layout, number of columns, posts per page, category, and more.
Shortcode: [eventbrite_events]
Parameters
Here is a list of all possible eventbrite_events shortcode parameters and attributes:
layout
– defines the layout style of the eventscol
– sets the number of columns in the events layoutposts_per_page
– determines the number of events displayed per pagecategory
– filters events based on specified categoriespast_events
– if set to ‘yes’, displays past eventsorder
– sets the order of events, either ascending or descendingorderby
– sets the parameter by which events are orderedstart_date
– filters events that start after the specified dateend_date
– filters events that end before the specified date
Examples and Usage
Basic example – Display Eventbrite events using default settings.
[eventbrite_events]
Advanced examples
Display Eventbrite events with a specific layout and column count. This example also sets the number of posts per page and specifies the categories of events to display.
[eventbrite_events layout="style2" col='2' posts_per_page='12' category="cat1,cat2"]
Display past Eventbrite events ordered in descending order. This example also sets the start and end date for the events to display.
[eventbrite_events past_events="yes" order="desc" start_date="2022-01-01" end_date="2022-12-31"]
Display Eventbrite events from a specific category, ordered by the event start date in ascending order.
[eventbrite_events category="cat1" orderby="event_start_date" order="asc"]
PHP Function Code
In case you have difficulties debugging what causing issues with [eventbrite_events]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'eventbrite_events', array( $this, 'eventbrite_events_archive' ) );
Shortcode PHP function:
function eventbrite_events_archive( $atts = array() ) {
// [eventbrite_events layout="style2" col='2' posts_per_page='12' category="cat1,cat2" past_events="yes" order="desc" orderby="" start_date="" end_date="" ]
$current_date = current_time( 'timestamp' );
$paged = ( get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1 );
if ( is_front_page() ) {
$paged = ( get_query_var( 'page' ) ? get_query_var( 'page' ) : 1 );
}
$eve_args = array(
'post_type' => 'eventbrite_events',
'post_status' => 'publish',
'meta_key' => 'start_ts',
'paged' => $paged,
);
// posts per page
if ( isset( $atts['posts_per_page'] ) && $atts['posts_per_page'] != '' && is_numeric( $atts['posts_per_page'] ) ) {
$eve_args['posts_per_page'] = $atts['posts_per_page'];
}
// Past Events
if ( ( isset( $atts['start_date'] ) && $atts['start_date'] != '' ) || ( isset( $atts['end_date'] ) && $atts['end_date'] != '' ) ) {
$start_date_str = $end_date_str = '';
if ( isset( $atts['start_date'] ) && $atts['start_date'] != '' ) {
try {
$start_date_str = strtotime( sanitize_text_field( $atts['start_date'] ) );
} catch ( Exception $e ) {
$start_date_str = '';
}
}
if ( isset( $atts['end_date'] ) && $atts['end_date'] != '' ) {
try {
$end_date_str = strtotime( sanitize_text_field( $atts['end_date'] ) );
} catch ( Exception $e ) {
$end_date_str = '';
}
}
if ( $start_date_str != '' && $end_date_str != '' ) {
$eve_args['meta_query'] = array(
'relation' => 'AND',
array(
'key' => 'end_ts',
'compare' => '>=',
'value' => $start_date_str,
),
array(
'key' => 'start_ts',
'compare' => '<=',
'value' => $end_date_str,
),
);
} elseif ( $start_date_str != '' ) {
$eve_args['meta_query'] = array(
array(
'key' => 'end_ts',
'compare' => '>=',
'value' => $start_date_str,
),
);
} elseif ( $end_date_str != '' ) {
$eve_args['meta_query'] = array(
'relation' => 'AND',
array(
'key' => 'end_ts',
'compare' => '>=',
'value' => strtotime( date( 'Y-m-d' ) ),
),
array(
'key' => 'start_ts',
'compare' => '<=',
'value' => $end_date_str,
),
);
}
} else {
if( isset( $atts['past_events'] ) && $atts['past_events'] === true ){
$atts['past_events'] = "yes";
}
if ( isset( $atts['past_events'] ) && $atts['past_events'] == 'yes' ) {
$eve_args['meta_query'] = array(
array(
'key' => 'end_ts',
'compare' => '<=',
'value' => $current_date,
),
);
} else {
$eve_args['meta_query'] = array(
array(
'key' => 'end_ts',
'compare' => '>=',
'value' => $current_date,
),
);
}
}
// Category
if ( isset( $atts['category'] ) && $atts['category'] != '' ) {
$categories = explode( ',', $atts['category'] );
$tax_field = 'slug';
if ( is_numeric( implode( '', $categories ) ) ) {
$tax_field = 'term_id';
}
if ( ! empty( $categories ) ) {
$eve_args['tax_query'] = array(
array(
'taxonomy' => $this->event_category,
'field' => $tax_field,
'terms' => $categories,
),
);
}
}
// Order by
if ( isset( $atts['orderby'] ) && $atts['orderby'] != '' ) {
if ( $atts['orderby'] == 'event_start_date' || $atts['orderby'] == 'event_end_date' ) {
if ( $atts['orderby'] == 'event_end_date' ) {
$eve_args['meta_key'] = 'end_ts';
}
$eve_args['orderby'] = 'meta_value';
} else {
$eve_args['orderby'] = sanitize_text_field( $atts['orderby'] );
}
} else {
$eve_args['orderby'] = 'meta_value';
}
// Order
if ( isset( $atts['order'] ) && $atts['order'] != '' ) {
if ( strtoupper( $atts['order'] ) == 'DESC' || strtoupper( $atts['order'] ) == 'ASC' ) {
$eve_args['order'] = sanitize_text_field( $atts['order'] );
}
} else {
if( isset( $atts['past_events'] ) && $atts['past_events'] === true ){
$atts['past_events'] = "yes";
}
if ( isset( $atts['past_events'] ) && $atts['past_events'] == 'yes' && $eve_args['orderby'] == 'meta_value' ) {
$eve_args['order'] = 'DESC';
} else {
$eve_args['order'] = 'ASC';
}
}
$col = 2;
$css_class = 'col-iee-md-6';
if ( isset( $atts['col'] ) && $atts['col'] != '' && is_numeric( $atts['col'] ) ) {
$col = $atts['col'];
switch ( $col ) {
case '1':
$css_class = 'col-iee-md-12';
break;
case '2':
$css_class = 'col-iee-md-6';
break;
case '3':
$css_class = 'col-iee-md-4';
break;
case '4':
$css_class = 'col-iee-md-3';
break;
default:
$css_class = 'col-iee-md-4';
break;
}
}
$eventbrite_events = new WP_Query( $eve_args );
$wp_list_events = '';
/* Start the Loop */
if ( is_front_page() ) {
$curr_paged = $paged;
global $paged;
$temp_paged = $paged;
$paged = $curr_paged;
}
$iee_options = get_option( IEE_OPTIONS );
$accent_color = isset( $iee_options['accent_color'] ) ? $iee_options['accent_color'] : '#039ED7';
$direct_link = isset( $iee_options['direct_link'] ) ? $iee_options['direct_link'] : 'no';
if ( ! iee_is_pro() ) {
$direct_link = 'no';
}
ob_start();
?>
<div class="iee_archive row_grid">
<?php
$template_args = array();
$template_args['css_class'] = $css_class;
$template_args['direct_link'] = $direct_link;
if ( $eventbrite_events->have_posts() ) :
while ( $eventbrite_events->have_posts() ) :
$eventbrite_events->the_post();
if( isset( $atts['layout'] ) && $atts['layout'] == 'style2' && iee_is_pro() ){
get_iee_template( 'iee-archive-content2.php', $template_args );
}else{
get_iee_template( 'iee-archive-content.php', $template_args );
}
endwhile; // End of the loop.
if ( $eventbrite_events->max_num_pages > 1 ) : // custom pagination
?>
<div class="col-iee-md-12">
<nav class="prev-next-posts">
<div class="prev-posts-link alignright">
<?php echo get_next_posts_link( 'Next Events »', $eventbrite_events->max_num_pages ); ?>
</div>
<div class="next-posts-link alignleft">
<?php echo get_previous_posts_link( '« Previous Events' ); ?>
</div>
</nav>
</div>
<?php
endif;
else :
echo apply_filters( 'iee_no_events_found_message', esc_html__( 'There are no upcoming Events at this time.', 'import-eventbrite-events' ) );
endif;
?>
</div>
<style type="text/css">
.iee_archive .iee_event .event_date{
background-color: <?php echo esc_attr( $accent_color ); ?>;
}
.iee_archive .iee_event .event_desc .event_title{
color: <?php echo esc_attr( $accent_color ); ?>;
}
</style>
<?php
do_action( 'iee_after_event_list', $eventbrite_events );
$wp_list_events = ob_get_contents();
ob_end_clean();
wp_reset_postdata();
if ( is_front_page() ) {
global $paged;
$paged = $temp_paged;
}
return $wp_list_events;
}
Code file location:
import-eventbrite-events/import-eventbrite-events/includes/class-import-eventbrite-events-cpt.php
Conclusion
Now that you’ve learned how to embed the Import Eventbrite Events Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply