Skip Navigation

[Resolved] Filter by multiple custom fields

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to filter a View by multiple custom field values, set by shortcode attributes.

Solution: Use the Query Filter panel to implement multiple custom field filters set by shortcode attributes.

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by Serhii 3 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1908165

Hello, please advise how to do it right.

Testing page - hidden link

This is custom type post - "Bonus". It has custom fields.

Every added bonus can be selected like:

- Deposit (hidden link)
-- 1) Free Spins
-- 2) Percentage for deposit

or

No Deposit (hidden link)
-- 3) Free Spins
-- 4) Free Money

or

- 5) Cashback (hidden link)

Total 5 types of bonus

For example this bonus hidden link is type 1 - Deposit - Free Spins

---------------------------

So my goal is to create a view that will show bonuses of the same type on the bonus page.

At this moment I have View which display all last added bonuses - hidden link , but this bonus hidden link is Deposit - Free Spins. So I need a filter that will automatically display bonuses of the same type as the current bonus.

I tried different filter options, but nothing worked - hidden link

#1908355
Screen Shot 2021-01-17 at 12.34.20 PM.png

Hello, it sounds like you need a View of Bonus Posts filtered by several custom field values, each one set by a shortcode attribute. Each custom field value should be identical to the current post's custom field value. See the screenshot here for an example of this type of Query Filter setup. I can show you how to create something similar, but I think I may need to log in to give you the best advice. I'm not quite clear how the custom fields are implemented. It seems that there are 3 different custom field groups: Casino Bonus - Deposit, Casino Bonus - No Deposit, and Casino Bonus - Cashback.
Each custom field group contains several custom fields, including a checkbox field and radio fields.

It seems you need to set up Custom Field Query Filters for each of these fields:
- Deposit Bonus Type
- No Deposit Bonus Type
- Cashback checkbox

Each filter should be set up to respond to a shortcode attribute. Then you must pass the current post's custom field values into the corresponding shortcode attributes, like so:

[wpv-view name="Your View of Bonus Posts" depositbonustype="[types field='your-deposit-bonus-type-field-slug' output='raw'][/types]" nodepositbonustype="[types field='your-no-deposit-bonus-type-field-slug' output='raw'][/types]" cashbackcheck="[types field='cashback-field-slug' output='raw'][/types]"]

The attribute names depositbonustype, nodepositbonustype, and cashbackcheck are arbitrary, but must be unique for each custom field. You must change your-deposit-bonus-type-field-slug to match the slug of the Deposit Bonus type custom field, change your-no-deposit-bonus-type-field-slug to match the slug of the No Deposit Bonus type custom field, and change your-cashback-field-slug to match the slug of the Cashback checkbox custom field.

It is a bit complex, so I may need to log in to give you better advice. If you need more information, please share login credentials in the private reply fields here. I'll take a look at everything and give you some feedback.

#1909563

Thanks, your advice helped me a lot My issue is resolved now.