Below, you’ll find a detailed guide on how to add the Display 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 Display Eventbrite Events Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Display Eventbrite Events Plugin and the shortcodes it provides:
"Display Eventbrite Events is a dynamic WordPress plugin that seamlessly integrates with Eventbrite API to display upcoming events on your website, providing an interactive user experience."
- [wfea]
Display Eventbrite Events [wfea] Shortcode
The Widget for Eventbrite API shortcode, ‘wfea’, is designed to query and display Eventbrite events on your website. It allows customizations and error handling. This shortcode performs a query to Eventbrite’s API, retrieves event data, and formats it for display. It also includes error messages for admin users if the query fails. The output is customizable through themes and filters.
Shortcode: [wfea]
Examples and Usage
Basic example – Display events from Eventbrite using the ‘wfea’ shortcode without any parameters. This will display events based on the default settings of the plugin.
[wfea /]
Advanced examples
Display events from a specific Eventbrite organizer. Replace ‘organizer_id’ with the actual ID of the organizer.
[wfea organizer_id="12345" /]
Display events in a specific layout. The available layouts are ‘widget’ and ‘card’.
[wfea layout="card" /]
Display events from a specific Eventbrite organizer in a specific layout, and enable debug mode. Replace ‘organizer_id’ with the actual ID of the organizer.
[wfea organizer_id="12345" layout="card" debug="true" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [wfea]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'wfea', array( $this, 'build_shortcode' ) );
Shortcode PHP function:
function build_shortcode( $initial_atts )
{
list( $atts, $query ) = $this->build_query_args_from_atts( $initial_atts );
global $wfea_instance_counter ;
$wfea_instance_counter++;
// Allow plugins/themes developer to filter the query.
$query = apply_filters( 'eawp_shortcode_query_arguments', $query );
$atts = apply_filters( 'eawp_shortcode_atts', $atts );
// Perform the query.
$events = new Eventbrite_Query( $query );
$html = '';
$admin_msg = '<div class="wfea error">' . esc_html__( '[Display Eventbrite Plugin] Admin Notice! ( this shows to admins only ): ', 'widget-for-eventbrite-api' ) . '</div>';
if ( is_wp_error( $events->api_results ) ) {
if ( current_user_can( 'manage_options' ) ) {
$error_string = $this->utilities->get_api_error_string( $events->api_results );
$html .= $admin_msg . '<div class="wfea error">' . $error_string . '</div>';
if ( $atts['debug'] ) {
$html .= $this->get_debug_output( $events );
}
}
} else {
ob_start();
$this->check_valid_att( $initial_atts );
$theme = wp_get_theme();
$template_loader = new Template_Loader();
$template_loader->set_template_data( array(
'template_loader' => $template_loader,
'events' => $events,
'args' => $atts,
'template' => strtolower( $theme->template ),
'plugin_name' => $this->plugin_name,
'utilities' => $this->utilities,
'unique_id' => uniqid(),
'instance' => $wfea_instance_counter,
'event' => new stdClass(),
) );
$template_found = $template_loader->get_template_part( 'layout_' . $atts['layout'] );
if ( false == $template_found ) {
if ( current_user_can( 'manage_options' ) ) {
$layouts = 'widget,card';
$plan_title = esc_html__( 'Free', 'widget-for-eventbrite-api' );
$err_msg = $admin_msg . '<div class="wfea error">' . esc_html__( 'Selected LAYOUT="', 'widget_for_eventbrite_api' ) . esc_html( $atts['layout'] ) . esc_html__( '" Not found in any paths. Your plan is ', 'widget_for_eventbrite_api' ) . esc_html( $plan_title ) . esc_html__( ' and includes these layouts ', 'widget_for_eventbrite_api' ) . esc_html( $layouts ) . esc_html__( ' and any custom developed layouts you have made.', 'widget_for_eventbrite_api' ) . '<br><br>' . esc_html__( 'Paths checked are:', 'widget_for_eventbrite_api' ) . '<br>' . implode( '<br>', $template_loader->get_file_paths() );
'</div>';
echo wp_kses_post( $err_msg ) ;
}
}
if ( $atts['debug'] ) {
echo wp_kses_post( $this->get_debug_output( $events ) ) ;
}
$html .= ob_get_clean();
$html = apply_filters( 'eawp_shortcode_markup', $html );
// Restore original Post Data.
wp_reset_postdata();
}
return $html;
}
Code file location:
widget-for-eventbrite-api/widget-for-eventbrite-api/frontend/class-frontend.php
Conclusion
Now that you’ve learned how to embed the Display 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