Home › Forums › Calendar Products › Filter Bar › Tribe_get_events is getting confused
- This topic has 12 replies, 3 voices, and was last updated 10 years, 2 months ago by
Support Droid.
-
AuthorPosts
-
February 22, 2016 at 8:34 am #1079814
Hill
ParticipantI am trying to hook into tribe_events_before_template and add a loop that always displays the next 4 Featured Category Events above the Tribe Bar and Filter Bar. I have created a function to do that but I can’t seem to seperate it from the Filter Bar Category. When ever I change the Event Category on the Filter Bar and then refresh the page, my loop now shows that category and I don’t seem to be able to lock in my search.
$fe_args = array( 'tribe_eventcategory' => 112, 'posts_per_page' => 4 ); // This grabs all the events based on the $fe_args $fe_events = tribe_get_events($fe_args); foreach ( $fe_events as $fe_events->$post ) { setup_postdata( $fe_events->$post );Any thoughts on what I’m missing?
Thanks!
February 22, 2016 at 8:57 pm #1080416Cliff
MemberHi Hill. Thanks for your question.
If I understood it correctly, I think you might like this Events Widget Areas plugin I created.
I tested it like this: http://cl.ly/362a0I080G1H
And it output above Filter Bar: http://cl.ly/2e1M3Y2V0E0i
You could turn your custom code into a custom widget or a shortcode and put it in a text widget.
I hope this helps. Please let me know.
February 24, 2016 at 8:44 am #1081512Hill
ParticipantThanks Cliff for the reply and the plugin. I’m able to hook into the tribe_events_before_template as can be seen at http://ltdstaging.com/events/ but my problem is that my query is somehow hooked to the filter bar query. The Event Category from the filter bar is overriding my query. Here’s my code that I’m using and my function that I call it with.
// Show Featured Events before the Tribe Bar function lrta_add_featured_events() { get_template_part( 'tribe-events/featured', 'events' ); wp_reset_postdata(); } add_action( 'tribe_events_before_template', 'lrta_add_featured_events', 10, 2 );How do I seperate the 2 queries? Also, am I using the right variable name for the event category in my args?
Thanks
February 24, 2016 at 9:42 pm #1081849Cliff
MemberCan I ask why you have “10, 2” if lrta_add_featured_events() doesn’t accept 2 arguments/parameters?
Could you please send me a video screencast of what you’re experiencing so I can know for sure what I’m looking for?
Thanks.
February 25, 2016 at 2:18 pm #1082196Hill
ParticipantSorry for the confusion on the “10,2” as I was trying different things at the time I grabbed that file. I don’t have any parameters in there now.
I did install the plugin that you sent earlier which works great but my challenge is that my client wants to have the Featured Image displayed and that is not an option using the Events List widget item.
Here is a screencast of what I’m seeing on my side. http://www.screencast.com/t/5byO5drex Hopefully this, along with the files I sent earlier will help pinpoint what’s going on.
Thanks again for all you help with this and I’m really diggin this plugin.
-
This reply was modified 10 years, 2 months ago by
Hill.
February 25, 2016 at 3:08 pm #1082217Cliff
MemberAwesome video. Thanks so much!
Your snippet is getting that template part, which is why it’s displaying the posts it’s told to display based on the URL you’re at when you do a full page reload/refresh.
It sounds like what you’re wanting is a static set of events to display, for which you should code your own customization. For example: start with that template part’s code to get all the divs and the featured images and such. But you’ll want to do it for a specific set of event/post IDs.
Please reference tribe_get_events(). You might want to use the “Sticky” (i.e. $post->menu_order is -1 instead of zero) option on the single event wp-admin edit screen (http://cl.ly/3L3L1L2y2b2n) and tribe_get_events( those sticky post IDs ), or you could just create a custom category (e.g. “Featured”) and get events from that category that have an end date after “right now”, for example.
If you need help coding something like this, you can reference our Find a Customizer page.
Let us know how things get along for you.
February 28, 2016 at 2:01 pm #1083105Hill
ParticipantCliff,
I do have an Event Category called ‘Featured’, id=112. Here’s the custom code that I’m using to query the events and display them in divs.
https://gist.github.com/dheckel77/4affcc9548afa7796e32
It appears that the variable tribe_eventcategory on line 10 is getting over ridden by the page url. How do I make that static?February 29, 2016 at 7:54 am #1083338Cliff
MemberWhere are you placing this code?
February 29, 2016 at 8:26 am #1083368Hill
ParticipantThis page is stored in my child theme in the tribe-events folder.
February 29, 2016 at 3:23 pm #1083599Cliff
MemberHere are some ideas:
- Maybe create a custom shortcode to do essentially the same thing. The category may not get overridden if you do that instead.
- Or you could unhook the category filter’s tribe_events_pre_get_posts filter, then rehook it again when your custom query is done.
If you can’t get it working with this information, please specify exactly where your custom PHP file is located in your child theme and what the filename is so I’ll be able to test the same way you are using it.
March 1, 2016 at 9:08 am #1083945Hill
ParticipantHi Cliff,
Great ideas…unfortunately neither worked for me.
So here is my setup. This is in my functions.php file.
// Show Featured Events before the Tribe Bar function lrta_add_featured_events() { get_template_part( 'tribe-events/featured', 'events' ); wp_reset_postdata(); } add_action( 'tribe_events_before_template', 'lrta_add_featured_events' );This calls the file my-theme/tribe-events/featured-events.php. The code is found in my previous post.
Thanks again for helping to track this down.
March 1, 2016 at 4:29 pm #1084096Cliff
MemberThanks for the update. This code:
get_template_part( 'tribe-events/featured', 'events' );might be the part that’s getting affected.
I’d instead suggest using our Events List shortcode or something like it within a Text Widget (note my previous link to my Event Widget Areas plugin).
Per our Scope of Support / Terms, we don’t provide customizations.
If necessary, you might need to reference our Find a Customizer page.
Sorry I can’t take this one all the way for you. I hope you get it!
March 16, 2016 at 9:35 am #1089768Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
This reply was modified 10 years, 2 months ago by
-
AuthorPosts
- The topic ‘Tribe_get_events is getting confused’ is closed to new replies.
