Tribe_get_events is getting confused

Home Forums Calendar Products Filter Bar Tribe_get_events is getting confused

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1079814
    Hill
    Participant

    I 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!

    #1080416
    Cliff
    Member

    Hi 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.

    #1081512
    Hill
    Participant

    Thanks 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

    • This reply was modified 10 years, 2 months ago by Hill.
    • This reply was modified 10 years, 2 months ago by Hill.
    #1081849
    Cliff
    Member

    Can 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.

    #1082196
    Hill
    Participant

    Sorry 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.
    #1082217
    Cliff
    Member

    Awesome 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.

    #1083105
    Hill
    Participant

    Cliff,

    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?

    #1083338
    Cliff
    Member

    Where are you placing this code?

    #1083368
    Hill
    Participant

    This page is stored in my child theme in the tribe-events folder.

    #1083599
    Cliff
    Member

    Here 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.

    #1083945
    Hill
    Participant

    Hi 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.

    #1084096
    Cliff
    Member

    Thanks 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!

    #1089768
    Support Droid
    Keymaster

    This 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.

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Tribe_get_events is getting confused’ is closed to new replies.