Excluding from Filter Bar

Home Forums Calendar Products Filter Bar Excluding from Filter Bar

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #1099910
    Joe
    Participant

    Good day,

    I’ve been setting up a custom page template, incorporating your plugin. This template includes two displays:

    1. A featured event at the top of the page.

    2. A calendar type view, listing all of the events.

    This is all working fine and dandy. However, I’ve run into an interesting predicament. When using the Filter Bar add-on, if I switch views (say, from the List to Map view), it filters the featured event as well.

    Is there a way to exclude a class from Filter Bar? Or any way around this?

    Thanks a bunch.

    #1099986
    Nico
    Member

    Hi Joe,

    Thanks for reaching out to us! I can help you here…

    I guess this depends on how you are getting this featured event. Can you describe how is the event getting there? If there’s a URL to see this in action better!

    Please let me know about it,
    Best,
    Nico

    #1100280
    Joe
    Participant

    Hello Nico,

    Thank you so much for reaching out to me. It would be amazing if you could help me sort this out.

    I will gladly send you a URL to the staging site. However, in the meantime, I thought that perhaps this would be easier for you:

    http://pastebin.com/yprKsZE7

    Basically, that bit of code is included in the site header. It’s just a simple WordPress query. It works like a charm. Except, when using the Filter Bar, it’s being filtered. However, there is one more detail that might be good for you to know:

    If you’re on the page and run the filter, it doesn’t filter the header event. It’s only if you switch calendar views. For example, say you filter the events in calendar view, and then change to the list view.

    Thank you so much for taking the time to investigate this. It’s much appreciated.

    – Joe

    #1100932
    Nico
    Member

    Joe,

    Thanks for sending the code over!

    So if I’m not getting it wrong the ‘header event’ is being modified by filter bar whenever the ‘filterbar parameters’ are present in the URL (switching views with filters active or reload a filtered view) but the ‘header event’ is not affected by the subsequent ajax-filters calls, right?

    The code make it’s much clearer but taking a look at the staging site will surely help as well.

    One last question you are using the code you’ve sent in header.php ?

    Thanks,
    Nico

    #1101116
    Joe
    Participant

    This reply is private.

    #1102145
    Nico
    Member

    This reply is private.

    #1103304
    Joe
    Participant

    Hello Nico,

    My apologies, I should have clarified this much more. As that site is very much so a work-in-progress, I completely spaced out the fact that the featured/header event isn’t currently on every page template.

    That being said, here is how you replicate it:

    – Use the filters on the home page.
    – Switch to another view (any view at all).
    – Then, switch back to the photo view (which is what I am using on the home page).
    – You will see, the header event is now missing.

    You might notice that the URL is no longer the home page. Regardless, the home page and that photo template are 100% the exact same template files.

    I cannot tell you enough how much I love this plugin. As you can see, this will be quite a custom design once I’m finished. It’s been fun to see just how much I can modify this to my needs, without breaking away from the plugin’s core functionality. Very great work that you’ve done here.

    Thanks so much, Nico. You are saving me a major headache here.

    – Joe

    #1104250
    Nico
    Member

    This reply is private.

    #1106102
    Joe
    Participant

    This reply is private.

    #1106800
    Nico
    Member

    This reply is private.

    #1106900
    Joe
    Participant

    This reply is private.

    #1107558
    Brook
    Participant

    Thanks for the thorough debugging steps! Nico has been a bit tied up but I’ll gladly pick up where he left off.

    So basically the difference you are seeing when switching views stems from the fact that switching views causes the entire page to reload. Where as switching filters causes only the events area to be reloaded via Ajax. Since your featured image is not within the events area it won’t get reloaded (and filtered) until you switch views or refresh the page in your browser.

    The root problem, as you pointed out, is that the Filter Bar is filtering your very standard WP_Query . Truth be told our queries kind of suck in this regard. When our plugin targets an event query there is a little bit of guessing that goes on, and in this case it is basically guessing wrong and targetting a query the plugin didn’t spawn. Some might call it a bug, others a limitation of our API. Regardless of what we call lets try to find a workaround that works for the current version of our plugin.

    What I would try to do is remove the Filter Bar’s action from the WP_Query  hook before running your query, then add it back after.

    remove_action( 'pre_get_posts', array( Tribe__Events__Query::class, 'pre_get_posts' ), 50 );
    
    // Do your beautiful magic
    
    add_action( 'pre_get_posts', array( Tribe__Events__Query::class, 'pre_get_posts' ), 50 );

    Would that work you think?

    Cheers!

    – Brook

     

     

    #1108506
    Joe
    Participant

    This reply is private.

    #1108513
    Joe
    Participant

    Hello again,

    After attempting to incorporate all of your helpful thoughts, to no avail, I tried the following. I removed this bit from the query:

    ‘post_type’ => ‘tribe_events’

    And, what do you know, it did the trick. Everything is working like a charm now.

    For anyone interested in setting this up, make sure that you set up a category from within this plugin. Then, call that category from within your query.

    For example, like so:

    		<?php
    		  $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
    		  $query_args = array(
    		    'tribe_events_cat' => 'Featured Header',
    		    'posts_per_page' => 16,
    			'order'	=> 'ASC',
    		    'paged' => $paged
    		  );
    		  $the_query = new WP_Query( $query_args );
    		?>

    In this case, the category is called “Featured Header”. Hopefully that saves someone some trouble sorting this out.

    Nico and Brook, thank you so much for your help here. I much appreciate it.

    – Joe

    • This reply was modified 10 years ago by Joe.
    #1108744
    Nico
    Member

    Hey Joe,

    Thanks for the heads-up and glad to hear you could work this out! Great finding 🙂

    Thanks as well for posting the final code for other users to benefit from it!

    I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.

    Have a great weekend,
    Nico

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘Excluding from Filter Bar’ is closed to new replies.