Skip Navigation

[Resolved] Custom wpv-control Filter Not Resetting URL parameters & Not taking Defaults

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 21 replies, has 2 voices.

Last updated by Minesh 11 months, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2672553

That's great, thanks for the prod in the right direction and yes, I really hope this is useful for someone one day as there's nothing worse than an incomplete thread!

#2672591

I've just discovered that this has somehow broken all of my other relationships driven Views and they're all returning no results! I'm just reopening the ticket while I investigate.

#2672593

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You should must make sure that the custom JS you added should be run only on your target view so you should try to adjust the JS code and target specific element under the view output ID 1137.

#2672595

I'm not sure at the moment, but it seems to be an issue with the wpv_filter_query_post_process function as when this hook is commented the rest of it works fine and having the JS there or not doesn't seem to make a difference.

#2672599

Ok, I'm narrowing it down. The no results issue is being caused due to the inclusion of this bit of code:

//If the filtered classes array is empty
    if( empty( $filtered_classes ) ){
      //Set the post count and found posts to zero and unset any left over posts
      $query->post_count = 0;
      $query->found_posts = 0;
      unset( $query->post );
    }

But that is working properly. The real issue is that the hook is executing all the code regardless of the View ID, which means this line isn't having the desired effect:

//If this is the Class Type Classes View (ID: 1137)
  if( $view_id = 1137 ){

And I'm not sure why at the moment.

#2672601

Oh, I'm so stupid! There was a typo!!!

I accidentally used a single = instead of a double ==

Do you have the ability to edit line 4 of the PHP section in my reply in post #2672057 to add the second = please? Obviously, it should read:

//If this is the Class Type Classes View (ID: 1137)
  if( $view_id == 1137 ){
#2672603

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've updated that line of code and you can mark resolve this ticket with different message like:
This is now resolved.

#2672605

Amazing, thank you!

So for anyone reading this, the code provided in my solution in post #2672057 is correct now!

Thanks Minesh.