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!
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.
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.
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.
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.
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 ){
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.
Amazing, thank you!
So for anyone reading this, the code provided in my solution in post #2672057 is correct now!
Thanks Minesh.