How to check whether an event is upcoming or passed in functions.php

Home Forums Calendar Products Events Calendar PRO How to check whether an event is upcoming or passed in functions.php

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1308210
    bjhdesign
    Participant

    Hi there,

    I added a button to the events description using the functions.php in the child theme.
    The code goes something like this:

    function extra_button() {
        echo do_shortcode('[button]');
        }
    add_action ('tribe_events_single_event_before_the_content', 'extra_button');

    It’s working fine, but I’d like the button to show up only when it’s an upcoming event.
    If the event is over, it’s still accessible through the archive, which is fine, but the button shouldn’t show up anymore.

    I guess I’ll have to use some conditional statement to check whether it’s an upcoming or passed event…
    Do you have any advice?

    #1308295
    Jennifer
    Keymaster

    Hello,

    Welcome back to the forums!

    I think tribe_is_past_event will help you out here – it will tell you if the current event has passed or not. We also have a thorough list of functions that are very helpful when making customizations, so I would recommend taking a look at that as well.

    Let me know if that works for you!

    Thanks,

    Jennifer

    #1308313
    bjhdesign
    Participant

    works like a charm 🙂 thanks!

    #1308468
    Jennifer
    Keymaster

    Awesome! Since this thread has been marked “resolved”, I’ll go ahead and close it out. Feel free to open a new one if you have any further questions!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘How to check whether an event is upcoming or passed in functions.php’ is closed to new replies.