Skip Navigation

[Resolved] Filtering Taxonomies by Posts Already Filtered on Page by Distance Filter

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
- 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 5 replies, has 3 voices.

Last updated by Waqar 3 months, 3 weeks ago.

Assisted by: Waqar.

Author
Posts
#2696178
Screenshot 2024-05-06 at 4.58.25 PM.png

Hello,

I LOVE Toolset!! I am using Legacy, and have a nested view working ALMOST perfectly here: hidden link

The view uses an address or zipcode in the URL parameter "mapcenter" to display projects we've completed, filtered to a 15 mile radius from the map center (which, I would LOVE to figure out how to display the map center as a different pin). The map is properly listing the projects, filtered an all. To achieve this, I'm using a CPT view of our "Completed Projects". I'm only displaying the map, and no content for each loop item.

NEXT, and below the map, is a tabbed body that uses the theme's tabbed CSS. The LEFT vertical column is a tab for each taxonomy, and the box to the right represents the nested posts that belong to the taxonomy. For example, the first taxonomy is "Custom Home (42)", with the associated filtered records.

This all LOOKS right, except for one piece -- the Taxonomies are NOT filtered. I've checked the box to ensure empty taxonomies don't show, and that works for taxonomies that are, infact, empty. BUT, in this case, the taxonomies displayed all have at least ONE (1) post (see post count next to the taxonomy name -- important to note that the numbers displayed are TOTAL posts, not the number of filtered posts...my problem), but some of them have posts that are filtered out because of the distance filter, but the taxonomy STILL shows up.

DESIRED EFFECT: Using the link above, the following Taxonomies have NO posts (filtered), so they show "No items found": Tract Home, RV Garage & Workshop/Shed. Instead, I just want the taxonomy to not show at all.

I've tried filters for the taxonomy, like term, parent and search, but none seem to work. I've also tried putting the Posts View in the taxonomy in the loop, but it errors out with a 502. I'm hoping you can help assist.

#2696245

Nigel
Supporter

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

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

Hi there

I looked at the page you linked to.

It's hard to advise you how to fix the problem, as I'm still not sure how exactly this is set up.

From the page source I see that the map and the categories appear to be generated by the View with ID = 859, while the actual posts are output by another—nested—View, with ID 872.

For the two to produce consistent results means applying the same filters to both Views, but as I don't know what each View is querying I don't know how feasible it is to set that up.

Can you share more details about the two Views, what content each is querying, and the query filters applied to each?

#2696334

View 859 is what displays the map and markers, filtered by distance from URL Parameter "mapcenter"

View 872 is what displays the posts, filtered by the same distance settings at 859 and by the parent taxonomy. This is nested in the Taxonomy view

View 867 is what displays the taxonomies. This is the parent view to 872. Each of the items in View 872 properly display under the taxonomy as expected.

BUT, since I have a filter applied to 859/872, not all the taxonomies that display in 867 have posts -- I'd expect it to be blank, but it still shows a post count -- because it's outside the loop, I'm guessing.

There doesn't appear to be a native way to filter Taxonomies by a Post View...which seems odd. I'm basically trying to list Posts nested under the proper taxonomy, BUT ONLY show the taxonomy if there are any posts after the distance filter is applied.

I've been reading about "wpvrelatedto"...just can't figure it out!

#2696630

Hi,

Thank you for sharing these details.

This will most likely require some restructuring of views, since in the current setup, the count of taxonomy terms with posts, relies on multiple views.

Can you please share the temporary admin login details in reply to this message? I'll be in a better position to suggest the next steps, accordingly.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2697443

Just circling back after the weekend. Thanks in advance for any updates.

#2697574

Thank you for waiting, after reviewing the requirements and the existing views, I've managed to make this work using a slightly different approach.

You can see the result on the page named 'Test Page from TS support'.

It uses three views:

1). Map for Projects Nearby Address with URL Param - New:

This is a post view to show the list of 'Completed Projects' posts, based on the distance filter.

Its role is to only bring in the results and those results are actually hidden from the page.

The actual presentation of those results is carried out by the following views.

2). Nested - Jobs inside Project Type Tab - New:

This is a taxonomy view to show the 'Completed Project Types' and creates the HTML structure for the tab's navigation menu.

3). Nested - Jobs inside Project Type Tab__Content - New:

This is also a taxonomy view to show the 'Completed Project Types' and create the HTML structure for the tab's content area.

Lastly, some custom script is used in the 'Map for Projects Nearby Address with URL Param - New' view to do the following operations:

a). Copy the result items from the first view, into the relevant tab content sections, based on the taxonomy terms.
And
b). Count items added into those sections and add that counter to the tab's navigation labels:


jQuery(document).ready(function( $ ) {
	$('.js-wpv-view-layout .result-items').each(function(i)
	{
		var dataCat = $(this).attr('data-cat');
		$('.tabbed-content .tab-panels > .panel[aria-labelledby="'+dataCat+'"]').append($(this).html());
	});
	$('.tabbed-content .tab-panels > .panel').each(function(i)
	{
		var dataCat = $(this).attr('aria-labelledby');
		var dataCatCount = $(this).find('.row').length;
		$('.tabbed-content .nav-tabs > .tab[id="'+dataCat+'"] span strong').append('('+dataCatCount+')');
		if(dataCatCount == 0) {
			$('.tabbed-content .tab-panels > .panel[aria-labelledby="'+dataCat+'"]').remove();
			$('.tabbed-content .nav-tabs > .tab[id="'+dataCat+'"]').remove();
		}
	});
});

#2698208

Thanks a million! Works like a charm 🙂

Russell confirmed that the issue was resolved on 2024-05-16 17:26:43.
This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.