Can you tell me what the code looks like, if I want to exclude a category udsing shortcodes. Excluding by ID, that is.
Best regards
Steffen Innonet
Hi Steffen,
Apologies for the delay in getting back to you on this!
Unfortunately this isn’t possible with the [eo_events]
shortcode. For something like this its probably easiest to create your own shortcode.
The following should do roughly what you want.
Usage: [events_excluded_cats exclude_cats="1,12,18"]
add_shortcode( 'events_excluded_cats', 'innonet_events_excluded_cats_handler' );
function innonet_events_excluded_cats_handler( $atts, $content = null ){
$query = array(
'numberposts'=>5,
'event_start_after'=>'today',
);
if( !empty( $atts['exclude_cats'] ) ){
$exclude = array_map( 'intval', explode( ',', $atts['exclude_cats'] ) );
$query['tax_query'] = array(
array(
'taxonomy' => 'event-category',
'operator' => 'NOT IN',
'terms' => $exclude,
'field' => 'id',
)
);
}
//Return mark-up of list (can use eventorganiser_list_event for simplicity).
return eventorganiser_list_events( $query, array(), 0 );
}
Stephen Harris
Thanks for the reply Stephen
This is what my code in my text widget looks like:
[eo_events numberposts=”6″ exclude_category=”93″ eo_events showpastevents=false] %start{j. F}% – %event_title% [/eo_events]
Se kalender
So my question is; In what file do I insert your piece of php code and will I just throw in [events_excluded_cats exclude_cats=”1,12,18″] in the above code in the widget as well?
Thanks
Steffen Innonet
Hey Steffen,
You can add that code to several different parts of the WordPress back-end such as in the functions.php file or in a custom plug-in.
Have a read of this post which explains it all: http://wp-event-organiser.com/blog/tutorial/where-should-i-put-code-from-the-tutorials/
Dario
Ok. Thanks. I´ll put the code in my functions.php
But what about the little bit of short code? So what about the short code – will I just throw in [events_excluded_cats exclude_cats=”1,12,18″] in the widget as well?
Steffen Innonet
Could anyone of you guys answer my last question on this thread about the bit of short code in the widget please?
Steffen Innonet
Hi Steffen,
Apologies, your reply slipped my radar…
[events_excluded_cats exclude_cats="1,12,18"]
would be used instead of the [eo_events]
shortcode
However, if you want to use the template tags you’ll need to make the following alterations:
Just before return eventorganiser_list_events( $query, array(), 0 );
put
$args = array(
'class'=>'eo-events eo-events-shortcode',
'template'=>$content,
'no_events'=>'',
'type'=>'shortcode',
);
and replace
eventorganiser_list_events( $query, array(), 0 );
with
eventorganiser_list_events( $query, $args, 0 );`
I’ve created this gist with an update version of the above code.
Stephen Harris