Shortcut Codes
WordPress Event Management, Calendars & Registration › Forums › General Question › Shortcut Codes
This topic contains 16 replies, has 2 voices, and was last updated by Stephen Harris 11 years, 10 months ago.
-
AuthorPosts
-
January 16, 2013 at 10:31 pm #2994
I’m having trouble showing only specific event categories.
I’m trying everything but it displays all the events from all categories no matter what.[eo_events events-category=’lake-stocking’]
[eo_events events_category=”lake-stocking”]
[eo_event events_category=”lake-stocking”]Any help would be great.
Thanks
Alfonzo BurtonJanuary 16, 2013 at 10:33 pm #2995I finally figured it out.
The documented attribute is events_category with an S and it works with event_category without an S.Thanks
Alfonzo BurtonJanuary 16, 2013 at 10:34 pm #2996Actually I see you have it right for some reason I was adding an S.
Good workAlfonzo BurtonFebruary 18, 2013 at 8:42 pm #3516I am having trouble to use the event_category attribute of the eo_events ShortCode.
I use the code
[eo_events showpastevents=false event_category=”evenement-interculturel”] %event_title% le %start{j M Y}{ g:i:a}%, au %event_venue% [/eo_events]
at the end of a page.
It does generate a list of events. But the list did not select only events from the category “evenement-interculturel” and instead generate a list of all the inputs.
I need help, since I don’t know how to debug or find info on what is wrong.
the page can be found at http://fssf.orgfree.com/?page_id=10
the event category as a name:
Evènement interculturel
and an id: evenement-interculturel.
I tried both name and id as the value for the event_category attribute: nothing is working as expected.
Thanks for your help.
GuillaumeFebruary 18, 2013 at 10:47 pm #3519Hi Guillaume,
Mmmm… its definitely not displaying the events it should on your site, but I’m unable to replicate the bug. Could you try disabling any other plug-ins and switching to Twenty Eleven/Tweleve theme to check that its not a plug-in conflict?
Stephen HarrisFebruary 20, 2013 at 11:52 am #3564I did as you asked. It did not improve the thing at all.
At least, the first glance you gave tell I am using the correct sytax ? right ?
How can you use some specific code (even in a template) to try to dig the problem ?
Can you give me some hint what to do or where to search ?
Thanks Stephen.
GuillaumeFebruary 20, 2013 at 11:54 am #3565Another question what is supposed to happen if the category I try to select do not exist ?
It should select nothing right ? Because right now it looks like it anyhow select all events.
Maybe it is some hint to you on where to search the problem.
Thx
GuillaumeFebruary 20, 2013 at 5:50 pm #3570Hi Guillaume,
Regarding selecting categories that do not exist – I’m not sure. The shortcode simply invokes
WP_Query()
– so whatever the defaut behaviour of that is when querying posts in a taxonomy that does not exist.As mentioned above, the shortcode invokes
WP_Query
and does this viaeventorganiser_list_events()
(source) – a terrible function that needs refactoring.Anyway, as you can see its a simple
WP_Query
– and the query variable may contain the ‘event-category’ key to query the events.The handler for the shortcode (which first turns the attributes into a query which
WP_Query
will understand before using the above), can be found here: https://github.com/stephenharris/Event-Organiser/blob/1.7.3/classes/class-eventorganiser-shortcodes.php#L142Stephen HarrisFebruary 21, 2013 at 11:23 am #3574Hi Stephen,
in the class-eo-event-list-widget.php file in function eventorganiser_list_events the call to the query is
$eo_event_loop = new WP_Query($query);
And in my case the query is an array containing
-1
event
“vide”
eventstart
ASC
1
“vide”
1
showpastevents=false
“vide”
event_category=”evenement-interculturel”question1 : Does this look right ?
question 2: The taxonomy is event-category. But in the doc it was stated that the attribute should be event_category and not the taxonomy.
Can you explain me the mecanism that let WP_Query know how to change event_category to event-category ? I don’t understant how this query could give us the good result unless the selection is done elsewhere ( in the eo_get_event_classes for instance ?)Thanks again for your time
GuillaumeFebruary 21, 2013 at 11:24 am #3575sorry my french was not translated. By “vide” I mean that it is an empty string.
GuillaumeFebruary 21, 2013 at 5:34 pm #3577I dug a little more:
in the file event-organiser-event-functions.php
in the function eo_get_event_classes
there is this final call to the filtering function:
apply_filters(‘eventorganiser_event_classes’, $event_classes, $post_id, $occurrence_id)
My question: eventorganiser_event_classes do not refer to any function in the plugin files. What is it ? A somehow database entry ?
can you help me understanding how this works ?Thanks.
Guillaume
GuillaumeFebruary 21, 2013 at 7:01 pm #3578The function
eo_get_event_classes()
simply returns an array of HTML classes corresponding to the event (see doc).The `apply_filters’ part simply allows other plug-ins/themes to add additional classes to that array or remove some.
The function doesn’t play any role in retrieving events, but simply, for specified occurrence generates HTML classes for that occurrence based on (for example) – the event venue/category. E.g. it includesthe class ‘eo-event-cat-evenement-interculturel’.
And yes, the attribute is ‘event_category’ while ‘event-category’ is the taxonomy name. The reason for this is that hyphens do not work well in shortcodes! The shortcode handler (see source) converts the shortcode attribute into something
WP_Query
will understand.Is there any relationship between ‘evenement-interculturel’ and ‘rtc’? That seems to be the only other category showing…?
Stephen HarrisFebruary 21, 2013 at 7:39 pm #3580Then there is something wrong in my case since, as I told you, the attributes that I see in my case and are directly passed to WP_Query are
-1 ; event ; “empty” ; eventstart ; ASC ; 1 ; empty ; 1 ; showpastevents=false ; empty ; event_category=”evenement-interculturel”
Where you can see the event_category was not changed. Where is made that call to “handle_eventlist_shortcode” function ?
Sorry to bug you. I don’t know much of WP_Query…. I hope I do not anoy you too much…
Thanks again.
G.
guillaumeFebruary 21, 2013 at 8:14 pm #3581Not at all 🙂
You won’t find an explicit call to it – its called automatically when the shortcode is parsed. Lines 143-149 are where taxonomy attributes are converted. You can check the input against the output. Then
$atts
array should contain the attributes and their values,e.g.array( 'showpastevents' => 1, 'event_category' => 'evenement-interculturel', )
The first thing that function does (should do) is replace
event_*
withevent-*
(for ‘category’, ‘venue’ and ‘tag’)Stephen HarrisFebruary 21, 2013 at 9:15 pm #3582There is something wrong:
the test:
foreach ($taxs as $tax){
if(isset($atts['event_'.$tax])){
$atts['event-'.$tax]= $atts['event_'.$tax];
unset($atts['event_'.$tax]);
}
fails .
The thing is that if I output the content of the atts array I get:
showpastevents=false
empty
event_category=”evenement-interculturel”To my understanding the entries are stored as vectors and not as a map so that
$atts[‘event_’.$tax]
makes no sense (the indexes are probably integers and not the attributes)
Does my remark make sense ?
Any hint ?
Guillaume -
AuthorPosts