Skip Navigation

[Resolved] Change Operator for view where category set by the page where this view is shown

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 4 replies, has 1 voice.

Last updated by albertoG-9 6 days, 23 hours ago.

Assisted by: Minesh.

Author
Posts
#2842748

Tell us what you are trying to do?
I am trying to create a view that filters content by the categories set by the parent page. I want this view to filter Content using the AND operator. Currently it works with an OR operator and i have no UI options to change that.

Is there any documentation that you are following?
no

Is there a similar example that we can see?
no

What is the link to your site?
hidden link

#2842811

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Can you please share admin access details and let me know what is your expected results.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2843343

Minesh
Supporter

Languages: English (English )

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

Thank you for sharing admin login. The shared admin access details works but I can only access the profile page. It seems that the admin capability is not granted.

Can you please gant admin capabilities to that user so that I can access the admin section without any restrictions.

I have set the next reply to private which means only you and I have access to it.

#2843351

I have updated the role to admin. Sorry for that.

#2843355

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

I've added the following view's filter hook "wpv_filter_query" to "Custom Code" section offered by Toolset:
=> hidden link

add_filter( 'wpv_filter_query', 'func_filter_taxonomy_with_and_clause', 99, 3);
function func_filter_taxonomy_with_and_clause( $query,$view_settings  ,$view_id ) {

    // Optional: limit to a specific View ID
    if ( (int) $view_id !== 10313 ) {
        return $query;
    }

  
  
    $query['tax_query'][0]['operator'] = 'AND';
  
   

    return $query;
}

More info:
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#adding-custom-php-code-using-toolset
- https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

#2843379

Thanks very much. this worked like a charm