Skip Navigation

[Resolved] Filter by category

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by nelsonT-2 3 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#1627533
sites-list.jpg
cat-checkboxes.jpg

Hi,

I'm a little stuck here with something I thought would have been pretty easy.

I have a CPT called Network Sites which has a taxonomy called Network Sites Categories.

I need to filter by categories (see first image with checkboxes) and the result needs to show the Network Sites titles by Category (i.e. the first filter is there to determine what will be the categories shown on the second page; see second image with listings).

I have created the View that shows the sites filtered by category, with the filter set to "Parent Taxonomy View". That works. I tried to create a taxonomy View, but can't filter, so I created a Taxonomy View that shows the taxonomies filtered with the option " Terms with ID set by the URL parameter", at first terms_id, not wpv-network-sites-category. That View shows a title and then calls the previous View.

I then tried to create a more general View (for Network Sites), more to just filter and call the other one to filter by categories using checkboxes... The problem (might not be the only one) is that when submitted, that sends the slug as the URL, and the Taxonomy can only filter by ID...

So, how can I make the two communicate (p.s. the filter and results are on two different pages)? Is the third View really required?

Also, I saw the Toolset Search (https://toolset.com/home/toolset-search/)... What is it exactly? Was wondering if I could use that, but finally there's no plugin about it... It's not Forms (formerly CRED Forms), so I don't know if it's just the Views filter...?

Thank you for your support.
Nelson

#1628519

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Nelson,

Thank you for contacting us and I'd be happy to assist.

To suggest the best way forward to link these two views, I'll need to see exactly how they're set up in the admin area.

Can you please share temporary admin login details, along with the link to pages where these views can be seen?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

The Toolset Search page that you mentioned just highlights the search form feature of Views and is not related to any separate plugin.

regards,
Waqar

#1629383

P.S. Please detail the steps you do, as I'll have to replicate it on the live site...

#1630017

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Nelson,

Thank you for sharing the admin access.

For step 1, you can create a new taxonomy view, that can create a custom form, where each term in the "Network Sites Categories" taxonomy is a checkbox, and value is set to use the term ID.
( please refer to the view named "View to generate Network Sites Category checkboxes" and the page named "Page 1" )

Example content from the "Loop Editor":


[wpv-layout-start]
[wpv-items-found]
<form action="[wpv-post-url item='4018']" method="get">
	<div class="form-group">
		<label for="wpv-network-sites-category">Network Sites Categories</label>
		<!-- wpv-loop-start -->
		<wpv-loop>
		<div class="checkbox">
			<label for="network-sites-category-[wpv-taxonomy-slug]">
				<input type="checkbox" id="network-sites-category-[wpv-taxonomy-slug]" class="js-wpv-filter-trigger" name="wpv-network-sites-category[]" value="[wpv-taxonomy-id]">
				[wpv-taxonomy-title]
			</label>
		</div>
		</wpv-loop>
		<!-- wpv-loop-end -->
	</div>
	<input type="button" class="wpv-reset-trigger js-wpv-reset-trigger" name="wpv_filter_reset" value="Clear">
	<input type="submit" class="wpv-submit-trigger js-wpv-submit-trigger btn btn-secondary" name="wpv_filter_submit" value="VIEW SELECTED CATEGORIES">
</form>
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

Please note how this custom form is set to submit to the same page's URL with ID "4018".

Important: this website is set to use the "Plain" permalink structure where each page's ID is appended in URL parameter, but for this custom form to work, you'll need to change that to a different permalink structure that uses page slugs.
( ref: https://wordpress.org/support/article/using-permalinks/ )

The next step would be to show the view "Network Sites Categories" that you have already created, below this custom form, but only once this form has been submitted.

For this part you can wrap that view's shortcode inside a conditional block, that checks whether the URL parameter "wpv-network-sites-category" is set or not:
( https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/using-shortcodes-in-conditions/ )


[wpv-conditional if="( '[wpv-search-term param='wpv-network-sites-category']' ne '' )"]
[wpv-view name="network-sites-categories"]
[/wpv-conditional]

As a result, when a visitor will submit the form on "Page 1" the IDs of the selected term IDs would be passed in the URL parameter on the same page, and when the page will refresh, only the results from the selected categories will show below.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1631359

My issue is resolved now. Thank you!

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