Skip Navigation

[Resolved] Filter Categories "Set by the current archive page" and "set by URL parameter"

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.

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 3 voices.

Last updated by kristofG 4 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1804197

hidden link
This page has 2 Views, 1 for the "large" post (limited to 1) and another View for the next 6 posts with pagination (offset by 1).
Both views are filtered by "Categories are: Set by the current archive page" which works really well and the Page template is set via Elementor conditions (not Toolset Content Template).

Our client also needs a Search field to search within that category.
So we need to use the above filter, but refine it with the search keyword from hidden link when visitor uses the search.

Problem is that we can only apply 1 filter for the Category: either by the current archive page or by an URL parameter, not both.

How can this be achieved?

#1805271

Nigel
Supporter

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

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

You are describing a "permanent" Query Filter (permanent because it applies with every page load), and a temporary front-end filter (it applies only when chosen by the user).

You cannot apply both at the same time for the same thing, the category cannot be set both by the current archive and by the value coming from a search parameter.

You would have to use code to implement this.

I would set up the View using the GUI so that it works with the search filters rather than according to the current archive.

You can then use the Views API, specifically the wpv_filter_query filter (https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query) and some custom code which checks to see if category has been set in the View arguments (because it was applied by a front-end search filter), and if not set it according to the current archive.

#1808483
Screenshot_1.jpg

Hi Nigel,

I understand it is not possible to combine the 2 category filters, so I followed your advice and I am now displaying the category posts via an url variable like hidden link which works great unfortunately I lose the good SEO of /category/whitepaper/ but at least this way it is compatible with the search.

Could you confirm this is the right setup, see screenshot, so we don't runt into problems later that I can't currently think of.

#1808507

Minesh
Supporter

Languages: English (English )

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

When you setup a filter using the URL param, it will grab the value from the URL param and filter the result.

That mean, whatever value will be passed to URL param using that value the posts will be filtered. So, there will be no issue as the value is grab from the URL param.

#1810395

My issue is resolved now. Thank you!