Home › Forums › Calendar Products › Community Events › Removing category from List Views BUT NOT from users My Events view
- This topic has 8 replies, 3 voices, and was last updated 7 years, 7 months ago by jussibr.
-
AuthorPosts
-
September 21, 2016 at 11:00 am #1167048jussibrParticipant
HI there –
I have been using the following code in my functions.php file to remove an event category from my main upcoming events view. The events are is still visible on the site when accessed directly by the category link. It works well except that it also seems to be removing these events from being listed on the ‘My Events’ page that a user sees when logged in. So users think the events have not been published. Is there a way to configure the code so that the events are still shown on the My Events page?
Thanks!
/* * The Events Calendar Remove Events from Month and List Views * add coding to theme's functions.php * @version 3.12 * modify here with event category slugs: array( 'concert', 'convention' ) */ add_action( 'pre_get_posts', 'tribe_exclude_events_category_month_list' ); function tribe_exclude_events_category_month_list( $query ) { if ( isset( $query->query_vars['eventDisplay'] ) && ! is_singular( 'tribe_events' ) ) { if ( $query->query_vars['eventDisplay'] == 'list' && ! is_tax( Tribe__Events__Main::TAXONOMY ) || $query->query_vars['eventDisplay'] == 'month' && $query->query_vars['post_type'] == Tribe__Events__Main::POSTTYPE && ! is_tax( Tribe__Events__Main::TAXONOMY ) && empty( $query->query_vars['suppress_filters'] ) ) { $query->set( 'tax_query', array( array( 'taxonomy' => Tribe__Events__Main::TAXONOMY, 'field' => 'slug', 'terms' => array( 'kids-camp-programs', 'kids-programs-and-workshops' ), 'operator' => 'NOT IN' ) ) ); } } return $query; }
September 21, 2016 at 3:39 pm #1167174AndrasKeymasterHello jussibr,
Thanks for using our plugins and for reaching out! I’ might be able to help you with this.
You will need to add another conditional statement to check if it is the My Events page or not. The function for it is tribe_is_community_my_events_page(). This does as says, tells you whether you are looking at the My Events page (true) or not (false).
I hope this helps. Let me know how it works out.
Cheers,
AndrasSeptember 25, 2016 at 5:18 am #1168473jussibrParticipantHi Andras – thanks for this. I am going to see if I can make it work. I will let you know how it goes!
September 26, 2016 at 1:15 am #1168617AndrasKeymasterGreat, looking forward to see how it works out! 🙂
Have a great start of the week!
Andras
September 28, 2016 at 8:49 am #1169830jussibrParticipantHi Andras,
Unfortunately writing this code appears to be above my skill level. Is there any way I can get more help with it?
Justine
September 29, 2016 at 2:49 am #1170265AndrasKeymasterHey jussibr,
No worries, let’s see how we can work this out.
I tweak the code a tiny bit so that the modified query is NOT run when you are looking at the My Events page.
Check if it helps.
https://gist.github.com/andrasguseo/60a26cd98acd4d6b077d25207f19e734
I didn’t understand correctly “still visible on the site when accessed directly by the category link”. Is that good like that or you want to hide them there as well?
Cheers,
AndrasSeptember 30, 2016 at 5:14 am #1170943jussibrParticipantHi Andras,
The new code works perfectly! Thank you so much for your help!
Justine
October 3, 2016 at 1:38 am #1171714AndrasKeymasterHey Justine,
I’m super happy it helped! 🙂
I am going to go ahead and close this ticket, but if you need help on this or something else, don’t hesitate to open a new topic. We’ll be here to help.
Cheers,
AndrasPS: We’d be grateful if you would give us feedback on your satisfaction with support. Just click on one of the classy looking emojis below. 🙂 If you can spare a few words, that’s even better. Thanks!
-
AuthorPosts
- The topic ‘Removing category from List Views BUT NOT from users My Events view’ is closed to new replies.