
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
I've adjusted the code as given under under the "Custom Code" section. I'm not sure how the original code I've added was updated. Maybe by mistake.
add_filter( 'wpv_filter_query_post_process', 'func_order_view_basedon_booking_from', 20, 3 );
function func_order_view_basedon_booking_from( $query, $view_settings, $view_id ) {
global $wpdb;
global $WP_Views;
if ( in_array( $view_id, array(11832,12025 ) ) ) {
if ( !empty( $query->posts ) ) { // if the query found no posts
$allposts = $query->posts;
foreach($allposts as $k=>$v):
$child_id = $WP_Views->view_shortcode_attributes[0]['wpvrelatedto'];
/*
$sql = $wpdb->prepare( "SELECT element_id FROM {$wpdb->prefix}toolset_connected_elements WHERE group_id in(
select intermediary_id from {$wpdb->prefix}toolset_associations where parent_id=(select group_id from {$wpdb->prefix}toolset_connected_elements where element_id=".$v->ID.") AND child_id=(select group_id from {$wpdb->prefix}toolset_connected_elements where element_id=".$child_id.")
)");
$res = $wpdb->get_results($sql, OBJECT);
*/
$intermediary_id = toolset_get_related_posts(array(
'parent' => $v->ID,
'child' => $child_id
),
'post-venue',
array(
'role_to_return' => 'intermediary'
));
foreach($intermediary_id as $x=>$y):
$date_array[$v->ID] = get_post_meta($y,'wpcf-booking-from',true);
endforeach;
endforeach;
}
// sorting the array
asort($date_array);
foreach($date_array as $k=>$v):
foreach($allposts as $x=>$y):
if($k==$y->ID){
$sorted[] = $y;
}
endforeach;
endforeach;
$query->posts = $sorted;
}
return $query;
}
Can you please confirm it works as expected now: hidden link
Hi Minesh,
The View has disappeared from the page: hidden link
It has also disappeared from your demo page: hidden link

Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
It should work OK now. Can you please confirm.
You Sir, are amazing! Thank you Minesh!
My issue is resolved now. Thank you!