Below, you’ll find a detailed guide on how to add the Event Organiser Posterboard 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 Event Organiser Posterboard Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Event Organiser Posterboard Plugin and the shortcodes it provides:
"Event Organiser Posterboard is a user-friendly WordPress plugin that simplifies event management. It allows you to visually organize, display, and manage your events in a posterboard layout."
- [event_board]
Event Organiser Posterboard [event_board] Shortcode
The Event Organiser Posterboard shortcode is designed to display events in a posterboard layout. It allows users to filter events based on venue, category, city, state, or country. The shortcode generates a unique ID for each event, which is used to localize the script and handle AJAX requests. It also enqueues the necessary scripts and styles, and handles the event filters, generating the appropriate markup for each. The shortcode returns a div element containing the event board, filters, and a load more button. The events are displayed in a posterboard layout, with the option to load more events. In conclusion, the Event Organiser Posterboard shortcode provides a flexible and interactive way to display events on a WordPress site.
Shortcode: [event_board]
Parameters
Here is a list of all possible event_board shortcode parameters and attributes:
filters
– Specifies the filters to be applied to the event board, such as ‘venue’, ‘category’, ‘city’, ‘state’, ‘country’.reversed
– If set to true, the order of the events displayed is reversed.posts_per_page
– Determines the number of events displayed per page.disable_css
– If set to true, the default CSS for the event board is not loaded.
Examples and Usage
Basic example – Displaying an event board with default settings
[event_board /]
Advanced examples
Displaying an event board with specified filters and reversed order
[event_board filters="venue,category" reversed="true" /]
Using the shortcode to display an event board with a custom number of events per page, and specific filters
[event_board posts_per_page=5 filters="city,state,country" /]
Displaying an event board with reversed order and no filters
[event_board reversed="true" filters="" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [event_board]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'event_board', 'eventorganiser_posterboard_shortcode_handler' );
Shortcode PHP function:
function eventorganiser_posterboard_shortcode_handler( $atts = array() ){
$defaults = array( 'filters' => '', 'reversed' => false );
$query = array_diff_key( (array) $atts, $defaults );
$atts = shortcode_atts( $defaults, $atts );
$id = uniqid();
$atts['reversed'] = ( 'false' === strtolower( $atts['reversed'] ) ? 0 : (bool) $atts['reversed'] );
$query = array_merge( array( 'posts_per_page' => 10 ), $query );
//Get template
ob_start();
eo_locate_template( 'single-event-board-item.html', true, false );
$template = ob_get_contents();
ob_end_clean();
//Load & 'localize' script
if( !eventorganiser_get_option( 'disable_css' ) ){
wp_enqueue_style( 'eo_posterboard' );
}
wp_enqueue_script( 'eo_posterboard' );
wp_localize_script( 'eo_posterboard', 'eo_posterboard_' . $id,
array(
'url' => admin_url( 'admin-ajax.php' ),
'loading' => __( 'Loading...', 'event-organiser-posterboard' ),
'load_more' => __( 'Load more', 'event-organiser-posterboard' ),
'template' => $template,
'query' => $query,
'reversed' => (bool)$atts['reversed']
)
);
//Handle filters
$filters = explode( ',', $atts['filters'] );
$filers_markup = '';
$venues = eo_get_venues();
$cats = get_terms( array( 'event-category' ), array( 'hide_empty' => false ) );
//'state'/'country'/'city' functions only available in Pro
$is_pro_active = in_array( 'event-organiser-pro/event-organiser-pro.php', (array) get_option( 'active_plugins', array() ) );
if( $filters ):
foreach( $filters as $filter ){
$filter = strtolower( trim( $filter ) );
switch( $filter ){
case 'venue':
if( $venues ){
foreach( $venues as $venue ){
$filers_markup .= sprintf(
'<a href="#" class="eo-eb-filter eo-eb-filter-venue eo-eb-filter-venue-%1$d" data-filter-type="venue" data-venue="%1$d" data-filter-on="false">%2$s</a>',
$venue->term_id,
$venue->name
);
}
}
break;
case 'category':
if( $cats ){
foreach( $cats as $cat ){
$filers_markup .= sprintf(
'<a href="#" class="eo-eb-filter eo-eb-filter-category eo-eb-filter-category-%1$d" data-filter-type="category" data-category="%1$d" data-filter-on="false">%2$s</a>',
$cat->term_id,
$cat->name
);
}
}
$filers_markup .= sprintf(
'<a href="#" class="eo-eb-filter eo-eb-filter-category eo-eb-filter-category-%1$d" data-filter-type="category" data-category="%1$d" data-filter-on="false">%2$s</a>',
0,
__( 'Uncategorised', 'event-organiser-posterboard' )
);
break;
case 'city':
case 'state':
case 'country':
//If Pro isn't active, this won't work
if( !$is_pro_active ){
break;
}
if( 'city' == $filter ){
$terms = eo_get_venue_cities();
}elseif( 'state' == $filter ){
$terms = eo_get_venue_states();
}else{
$terms = eo_get_venue_countries();
}
if( $terms ){
foreach( $terms as $term ){
$filers_markup .= sprintf(
'<a href="#" class="eo-eb-filter eo-eb-filter-%1$s eo-eb-filter-%1$s-%2$s" data-filter-type="%1$s" data-%1$s="%2$s" data-filter-on="false">%2$s</a>',
$filter,
$term
);
}
}
break;
};
}
endif;
return sprintf(
'<div class="eo-event-board" data-board="%s">'
.'<div class="eo-event-board-filters" data-filters="">'. $filers_markup . '</div>'
.'<div class="eo-event-board-items"></div>'
.'<div class="eo-event-board-more"></div>'
.'</div>',
esc_attr( $id )
);
}
Code file location:
event-organiser-posterboard/event-organiser-posterboard/event-organiser-posterboard.php
Conclusion
Now that you’ve learned how to embed the Event Organiser Posterboard 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