Add class to event through custom field

Home Forums Calendar Products Community Events Add class to event through custom field

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1002821
    Sine
    Participant

    Hi there,
    I have a specific type of events that I want to separate from others, and to achieve this I want to use a custom checkbox field and subsequently add a separate class to events if the custom field is checked. Is there a way to achieve this behaviour?

    /Soren

    #1003039
    George
    Participant

    Hey Soren,

    Thanks for reaching out! The whole concept you have is unfortunately not possible without some extensive code customization – that is something we unfortunately do not support here on the forums.

    With that being said, can you elaborate a bit on exactly what the distinction would be between these types of events? There are a number of classes generated already, like for specific Event Categories and such – you might be able to just create an Event Category and instead of a custom checkbox, and then use this category and use its related class name for the same effect you’d get out of the checkbox.

    Does that make sense? If this is not a sufficient enough solution, no worries! Elaborate a bit more on what you’re trying to do anyways, I’d happily share some more advice here and might be able to come up with a code example to get you started on a more robust customization here.

    Thank you!
    George

    #1003201
    Sine
    Participant

    Hi George,
    Thanks for your reply. I suppose I could make it work somehow using categories, although it’s not ideal with regards to my (very specific, I’ll admit) needs. Any chance you could just point me to the functions where the magic happens? I’m pretty sure I could figure a proper solution, but finding the actual function is a little bit like looking for trees in a forest; I wouldn’t know where to start.
    Best,
    /Soren

    #1003414
    George
    Participant

    Hey Soren,

    No problem! Thanks for being cool in regards to our policies about customizations and such. I totally relate to how finding functions is a bit tricky sometimes – fortunately, for this one, you can mostly pull off what you want by using the post_class filter in WordPress.

    You can learn more about this filter here → https://codex.wordpress.org/Function_Reference/post_class

    That filter lets you add the class names dynamically – for all the code and functions related to determining which class to add, this a bit specific to the things you need and I don’t know what exact functions would work best for your needs. However, if they’re mostly going to be taxonomy-related, then I’d recommend checking out functions like has_term()https://codex.wordpress.org/Function_Reference/has_term

    If you check out that has_term() article, at the bottom of it is a heap of related taxonomy functions, like in this screenshot → https://cloudup.com/cw–3qIIKiN

    Check out those functions in term and I’m sure that with a bit of time and playing-around-with-things, you’ll be able to start putting something useful together.

    Best of luck with your customizations! 🙂

    Cheers,
    George

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Add class to event through custom field’ is closed to new replies.