Remove events according to certain conditions

Home Forums Calendar Products Community Events Remove events according to certain conditions

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #813983
    louisecote
    Participant

    Hello.

    I want to create php function that removes all events according to my conditions.
    I’ve added additional meta field to Event class, this field stores date when event must be removed.
    Is there any simple way to get events by my meta field and remove them?

    #814187
    Josh
    Participant

    Hello louisecote,

    Thanks for reaching out to us!

    There are a couple of options that you could pursue to accomplish what you’re looking for.

    • <span style=”line-height: 13px;”>If you would like to use a conditional to control the display, you can follow the Themer’s Guide to copy the different primary views for our plugin into your theme. Then, you could wrap the call for the “single-event.php” files with your condition. Then, if the current post within the loop doesn’t match your condition it isn’t displayed. </span>
    • Another approach would be to use a function within your theme’s functions.php file. Within the function, you could modify queries using “pre_get_posts” with your custom meta field parameters. You could then wrap this entire logic around a conditional which checks if the current query is part of The Events Calendar.

    Hopefully this should get you pointed in the right direction to help you accomplish what you’re looking for. Let me know if there is anything else that I can help you with.

    Thanks!

    #814547
    louisecote
    Participant

    If I use WP_Query which post_type should I use?
    ‘post_type’=>’event’ or something else?

    #815244
    Josh
    Participant

    Hello louisecote,

    Thanks for following up with us!

    If you’re using WP_Query, the post type to use there will be “tribe_events”.

    Thanks!

    #815439
    louisecote
    Participant

    Thanks a lot!

    #816983
    Josh
    Participant

    Hello louisecote,

    No problem! I’m glad we were able to help!

    I’ll go ahead and close this ticket. If you have any further questions please don’t hesitate to open a new one.

    Also, If you have a few moments, we would definitely appreciate it if you took a second to rate our plugin on the WordPress.org repository.

    Thanks!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Remove events according to certain conditions’ is closed to new replies.