Event categories
WordPress Event Management, Calendars & Registration › Forums › General Question › Event categories
This topic contains 9 replies, has 2 voices, and was last updated by Stephen Harris 12 years, 9 months ago.
-
AuthorPosts
-
January 20, 2013 at 4:58 pm #3074
Hi everyone,
Currently I’m trying to show the event categories on the archive page (archive-event.php), however none of the WordPress functions seem to work.
In the documentation I’ve read that it should work with the regular wordpress functions. However all functions seem to return nothing / an empty array. I’ve tried wp_get_post_categories, get_the_category and more. Also I’ve used them without arguments (which should be possible in the loop?(while ( have_posts() ) : the_post();)) and while specifying a post ID.
Does anyone have a clue what this could be?
Also the event categories are separate from the post categories,it should still work though?
Thanks in advance, regards,
Tjibbe
Tjibbe
January 20, 2013 at 9:18 pm #3077Hi Tjibbe,
Functions such as
wp_get_post_categories()andget_the_category()refer to the taxonomy ‘category’. As you’ve said the event categories are separate from the post categories – and they belong to the taxonomy event-category.You can get the event category terms using
get_the_terms()or list them withget_the_term_list().Stephen Harris
January 21, 2013 at 11:13 pm #3089Hi Stephen,
Thanks alot! After some trial and error I managed to do exactly what I wanted.
Tjibbe
February 8, 2013 at 2:33 am #3345Hi guys,
i tried all codes found around on the web for to show event tags and categories but i’m not able to do it and i’m not so good with code, can u give me a little help?
I tried this code but i think it’s not right …
get_the_term_list ( get_the_ID(), ‘event-category’, ”, ‘, ‘,”);Luca
Luca
February 9, 2013 at 2:30 pm #3370Hi Luca,
That looks right. Are you using that inside the loop? (i.e. make sure
get_the_ID()is returning an ID!). Also,get_the_term_list()returns the HTML, so you would still need toechoit. (You can see an example of it here: https://github.com/stephenharris/Event-Organiser/blob/1.7/templates/event-meta-event-single.php#L66).Stephen Harris
February 9, 2013 at 3:24 pm #3374Hi Stephen,
txs a lot for your answer and the exemple link i will work on in the next days for to undestand how to use it, i’m customizing that page for create an “agenda” page, i’m using the code inside the the single-event.php and archive-event.php in a div … i will let you know if i’m able to do it!!
P.S.
i forgot to congratulate for the great plugin!! txss 😉luca
February 13, 2013 at 7:44 am #3412Would it be possible to change the categories so it is a single-selection mode? Currently multiple categories can be selected for one calendar entry.
Also I have a problem with the Venues. I need to hide the “add venue button” in the edit page. Access to venues management is restricted in the options panel but users can still add their own venues when adding or editing calendar entries.
Could you help?
Many thanks in advance.
P.S. Great Add-on!!!!!
JaGrom
February 13, 2013 at 10:05 am #3414Hi JaGrom,
Thanks! There’s no native support for ‘single selection’ of event categories. But this plug-in should help do that: http://wordpress.org/extend/plugins/radio-buttons-for-taxonomies/
That the add venue button appears is a bug, and I’ll be fixing that in 1.7.2. Thanks for reporting it!
Stephen Harris
February 15, 2013 at 6:27 am #3429Hi Stephen,
Thanks for the tip with the Radio Buttons for Taxonomies plugin. It is now working as I wanted.
I’ve also updated event organiser to the latest version and the venue button is working properly now. Thank you for fixing that.I would have just one more question. Do you know if it is possible to setup a mandatory field in the edit form?
I would like to force users to always select a category and a venue when adding or editing an event.Many thanks for your support. I can’t wait for the Pro version.
Regards,
JAGJaGrom
February 15, 2013 at 10:14 am #3430Hi JAG,
No problem 🙂 (And should be about in March !)
Yes it is possible – but again you’ll need some custom code (I’m not aware of a plug-in that does this automatically – and if they do, it might not work with the venues – would all depend on what order the plug-ins ran). Anyway, I posted an answer a while back which is very similar: http://wordpress.stackexchange.com/questions/46398/check-before-publishing-if-already-exist-post-with-current-custom-field-value/46406#46406
In particular that answer refers to this one: http://wordpress.stackexchange.com/questions/42013/prevent-post-from-being-published-if-custom-fields-not-filled/42178#42178 (about how to revert a post that’s just been published). To ensure that Event Organiser has ‘done its thing’ use priority 15+ for the
save_posthook. Or alternatively useeventorganiser_save_eventinstead ofsave_post– remember to change it everywhere as the function needs to ensure an infinite loop isn’t created!In the linked answers they wanted to check a custom field didn’t exist with the same value. In your case you’d be changing that check with, ‘do they have an event-category and event-venue taxonomy term set?’. You can check that with
get_the_terms()Stephen Harris
-
AuthorPosts