Skip Navigation

[Resolved] Combining different custom field filters into one custom field filter

This support ticket is created 4 years, 2 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.

Our next available supporter will start replying to tickets in about 7.14 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by deliap 4 years, 2 months ago.

Assisted by: Nigel.

Author
Posts
#1501619
Screenshot from 2020-02-10 12-14-06.png

Tell us what you are trying to do?
Combining different custom field filters (filters for blog date, report date and webinar date) into one custom field filter (date)
I have considered making another CPT combining the custom post types (blog, report and webinar) but that way if I want to add a post in blog, I would also have to add a copy in that combined custom post type.

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
hidden link

#1501643

My issue is resolved now. Thank you!

#1501649

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Let me see if I have this right.

You have 3 different post types (blog, webinar, report), each of which has its own date custom field.

You created a View which will query any of these 3 post types, and you want a single date filter control that provides a value to filter the posts by their respective date custom field.

Is that correct?

Your screenshot shows the Query Filters resulting from inserting the 3 filter controls (one for each date).

You should be able to delete the markup for two of the filter controls, leaving only one. Update the text label to something that makes sense, and then edit the URL parameter generated by that filter control, e.g. to wpv-date or something similarly generic.

Now edit the Query Filters so that each of the date field filters listens to the wpv-date parameter instead of the current setting (e.g. change wpv-wpcf-report-date to wpv-date etc.).

Then, that one control should provide the value for each of the three filters.

#1506955
Screenshot from 2020-02-13 12-32-54.png
Screenshot from 2020-02-13 12-26-25.png

Yes, you are correct.

I am facing a problem during the process of setting up the view. The problem appears after I click the submit button on the search page, "nothing's found" will show up.

I have tried field = "wpcf-date", and field="wpcf-blog-date, wpcf-report-date, wpcf-webinar-date", but both have the "nothing's found" problem.

Thanks.

#1507013

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screenshot 2020-02-13 at 13.25.47.png

It's not entirely obvious how to do this, so I set up a test site to verify for myself what's required.

I've a similar setup, with 3 CPTs (Alphas, Betas, Gammas) each of which has its own date field (e.g. alpha-date), and I want to create a View that will include a single date filter which operates across the 3 date fields so that posts of any CPT that match the date requirement are shown.

Now, the solution to your particular problem may be as simple as—from your screenshot—you are combining the date filters with AND when it should be OR, they cannot all simultaneously be true for each post.

Otherwise, what I did was I inserted a custom date filter and then made edits as required.

For my filter control I used the more generic wpv-control shortcode with a version of the field which wasn't an actual field, i.e.

<div class="form-group">
	<label for="wpv-wpcf-alpha-date">[wpml-string context="wpv-views"]Custom Date[/wpml-string]</label>
	[wpv-control type="datepicker" field="alpha-date" url_param="wpv-custom-date"]
</div>

I then edited the resulting Query Filter and inserted additional filters for the other date fields, all listening to the same URL parameter, being sure to combine with OR rather than AND.

You can see details in the screenshot.

I tested it and it worked, so hopefully that will enable you to achieve the same.

#1507109

Thanks, I changed AND to OR and everything's working now.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.