Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // show only items without relationship
- function func_check_item_has_child( $query, $view_settings, $view_id ){
- if ( in_array( $view_id, array( 70693) ) && !empty( $query->posts ) ){
- $all_posts = $query->posts;
- foreach ($query->posts as $key => $parent) {
- // get the child posts of the parent post
- $children = toolset_get_related_posts(
- $parent->ID,
- 'related-' .$parent->post_type,
- 'parent',
- 1,
- 0,
- array(),
- 'post_id',
- 'child'
- );
- if ( !empty($children) ) {
- unset( $query->posts[$key] );
- $query->found_posts = $query->found_posts - 1;
- $query->post_count = $query->post_count - 1;
- }
- }
- $query->posts = array_values( $query->posts );
- }
- return $query;
- }
- add_filter( 'wpv_filter_query_post_process', 'func_check_item_has_child', 1001, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement