Event categories

This topic contains 9 replies, has 2 voices, and was last updated by  Stephen Harris 11 years, 2 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #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
    #3077

    Hi Tjibbe,

    Functions such as wp_get_post_categories() and get_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 with get_the_term_list().

    Stephen Harris
    #3089

    Hi Stephen,

    Thanks alot! After some trial and error I managed to do exactly what I wanted.

    Tjibbe
    #3345

    Hi 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
    #3370

    Hi 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 to echo it. (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
    #3374

    Hi 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
    #3412

    Would 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
    #3414

    Hi 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
    #3429

    Hi 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,
    JAG

    JaGrom
    #3430

    Hi 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_post hook. Or alternatively use eventorganiser_save_event instead of save_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
Viewing 10 posts - 1 through 10 (of 10 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.