Skip Navigation

[Resolved] Taxonomy filter disappears when AJAX is selected

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 3 replies, has 1 voice.

Last updated by nedG 2 hours, 35 minutes ago.

Assisted by: Minesh.

Author
Posts
#2793211
Vendors2.jpg
Vendors.jpg

I have created a View and for Vendors/Suppliers Custom post. I am not using Blocks.

The results will be filtered by the taxonomies "Alphabet Letter" (a Parent View) and also by the taxonomy "Supplier Decor Category" which will be in checkboxes

Everything seems to be working great. The shortcode for the parametric search is on the left column and and the results are on the right column.

However, I want the visitors to be able to place a checkbox in the Supplier Decor Category on the left and have the appropriated results appear automatically on the right side... so I chose
"AJAX results update when visitors change any filter values" under Custom Search Settings

When I do this... the parametric search options disappear on the left side.

#2793249

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

The reason why you experience such thing is because you added the view's search result as nested view.

To fix the search form missing - I've adjusted the "Custom Search and Pagination" setting for the following view to:
- Let me choose individual settings manually -> Always show all values for inputs
=> hidden link

Now you will be able to see the search filter: hidden link

But you will have to add Search button as you added the view result as nested view.

#2793297

But I don't want to add a Search button. Is there a way to get this to work using AJAX and having the results update when a filter value is changed?

#2793557

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

Actually - it was not working and it suppose to not work as you added view "suppliers-belonging-to-alphabet-letter" within the loop of the "alphabet-letters" view:
- hidden link

[wpv-view name="suppliers-belonging-to-alphabet-letter" view_display="layout"]

It was not easy but I'm happy that I've a solutin to offer to. I've deleted the "alphabet-letters" view that you display using Divi builder:
- hidden link

I've added the following code to "Custom Code" section offed by Toolset:
=> hidden link

//group by tax char
add_shortcode('heading', 'func_tax_group_heading');
function func_tax_group_heading($atts, $content = '') {
  static $char = null;
  
  $condition = $atts['condition'];;
  $value = $atts['value'];;
  switch ($condition) {
    case 'char':
      if ($$condition != $value) {
        $$condition = $value;
        return $content;
      }
      break;
  }
  return '';
}

With the view "suppliers-belonging-to-alphabet-letter" - I've added the following code to the "Loop Editor" section and adjusted the code as given under:
=> hidden link

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop wrap="4" pad="true">
        
		[wpv-item index=1]
      [heading condition="char" value="[wpv-post-taxonomy type='alphabet-letter' format='name']"]
    	  <div class=""><div class="alphabet-title"><a name="[wpv-post-taxonomy type='alphabet-letter' format='name']"></a>[wpv-post-taxonomy type='alphabet-letter' format='name']<div class="pull-right top-link"><a href="#top"><i class="fas fa-caret-up"></i></a></div></div>
 <div class="clearfix"></div></div>
[/heading]
		<div class="row ">
          
          	<div class="col-sm-3">[wpv-post-body view_template="loop-item-in-suppliers-belonging-to-alphabet-letter"]</div>
		[wpv-item index=other]
			<div class="col-sm-3">[wpv-post-body view_template="loop-item-in-suppliers-belonging-to-alphabet-letter"]</div>
		[wpv-item index=4]
			<div class="col-sm-3">[wpv-post-body view_template="loop-item-in-suppliers-belonging-to-alphabet-letter"]</div>
		</div>
		[wpv-item index=pad]
			<div class="col-sm-3"></div>
		[wpv-item index=pad-last]
			<div class="col-sm-3"></div>
		</div>
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/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]

As you may notice I've added the following code that will display the grouping taxonomy character:

[heading condition="char" value="[wpv-post-taxonomy type='alphabet-letter' format='name']"]
    	  <div class=""><div class="alphabet-title"><a name="[wpv-post-taxonomy type='alphabet-letter' format='name']"></a>[wpv-post-taxonomy type='alphabet-letter' format='name']<div class="pull-right top-link"><a href="#top"><i class="fas fa-caret-up"></i></a></div></div>
 <div class="clearfix"></div></div>
[/heading]

Later, I've updated the Divi template code as given under:
=> hidden link

[wpv-view name="alphabet-letters-anchor-link"]
<div>[wpv-view name="suppliers-belonging-to-alphabet-letter" view_display="layout"]</div>

Now, you can filter the result without using Search button and the output is also exactly the same as before. I hope the soltuion I share will help you to resolve your issue.

More info:
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#adding-custom-php-code-using-toolset
- https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/

#2793653

Thank you