Skip Navigation

[Resolved] Category filter dropdown/select instantly resets itself to default value

This support ticket is created 5 years, 12 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 11 replies, has 3 voices.

Last updated by christianS-13 5 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#1199177

I am trying to: Select a category from the filter dropdown and then search to filter the results

Link to a page where the issue can be seen: hidden link

I expected to see: Select a Test Category from the dropdown filter. Then I should be able to press search and the search functions runs

Instead, I got: Whatever category is selected, the dropdown instantly reverts to the default 'All Categories' value before you even have time to perform the search.

This used to work as expected. We have recently upgraded to WordPress 5.0 and the latest Toolset plugins as well as updating all other plugins and the theme, and it seems one of these upgrades has caused the problem.

#1199266

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Christian,

Thank you for contacting our support forum.

I was able to clearly see the issue. This is actually quite strange as i've never encountered this before.

Might I suggest that if you haven't tried this as yet is to temporarily disable the non-toolset plugins and check again.

If this doesn't work I would remove the filters from the view and save it, then re-add the filters back to the view and see if the issue still remains.

Looking forward to hearing from you with these tests.

Thanks,
Shane

#1199363

Hi Shane,

I've tried disabling plugins to no avail. When I switch off the Fusion plugins the page breaks but the dropdown still does the same thing, so I think we can rule out the theme.

I've also tried removing the filters and re-adding them and it still does it.

What I have discovered is that if I change the "How do you want to update the results?" option to be "Full page refresh when visitors click on the search button" rather than "Full page refresh when visitors click on the search button with input values auto-updating" then it stops reverting to the default. However the list of categories in the dropdown is then incorrect (showing items with a count of 0). So that's not really a satisfactory solution as I want the fields to auto-update before and after selection. Clearly it's this auto-updating that's the source of the problem though.

And just to be really weird, there is one category which this issue doesn't occur on - "Malware Analysis Sandbox Testing" doesn't revert to default, whilst all the others do. Try it. Strange!

Many thanks,
Chris

#1199433

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Christian,

Thank you for performing these steps for me.

Would you mind providing me with admin access to the site so that I can have a look at the search in more details ?

Also if needed can I take a copy of the site to test locally as well as to escalate to our 2nd tier supporters if that step is needed/

The private fields have been enabled.

Thanks,
Shane

#1199969

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Christian,

Thank you for the credentials.

Is there any custom coding on the site ? I checked the JS editor on the view and the code here seems to not be the cause of the issue.

If there is any other area where custom coding is added please let me know so that I can check that as well.

Thanks,
Shane

#1200075

Hi Shane,

Not that I can think of really. There is a small amount of JS added via the Avada theme options which manipulates the page title on various pages. It's at Avada Theme Options > Advanced > Code Fields. And there are a few overridden functions in the functions.php of the active child-theme.

Hope that helps.

Chris

#1200243

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Christian,

That is strange as when I delete the filters completely from the view and re-add it the issue was resolved.

Could you check on your end and let me know if the issue still remains ?

Thanks,
Shane

#1200387

Hi Shane,

I think we're getting to the bottom of this. It was working for me, but I then spotted that the filter you had added wasn't exactly the same as mine and when I switched it back, the issue came back. So the issue is to do with the Taxonomy filter set by the URL parameter.

I had it set to "The service name is any of the values..." and when you recreated it it was set to "The service slug is any of the values...". As I say, if you switch it to Service Name, the issue comes back and if it's set to Service Slug, it goes away.

There's a couple of things to mention here then. Firstly, the reason I was using Name and not Slug (which I realise is a bit more robust as it doesn't include spaces) is because I use the URL parameter to append the page title using Javascript.
Secondly, this used to work, so the fact it doesn't any more suggests a code change now prevents it from working.

Obviously in the short term I can leave it set to Slug so that the search works, but I would like to see if it's possible to still use Name so that the page title reads as a name and not slug. Or if you can suggest another way I can access the selected Tax name for the page title, then I'm open to a different approach.

Thanks for your help,
Chris

#1200521

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Christian,

I tested this on a fresh install and it works fine.

How are you adding the Title to the page ? because what we can so is to get the slug that is being used and get the title from the slug by retrieving the taxonomy.

However I would need to know how you are getting this because I should be able to write a shortcode for this.

Please let me know.
Thanks,
Shane

#1201009

Hi Shane,

Sorry for the delay in responding.

I've got a bit of javascript which is applied in the loop editor of the Toolset Test view. It checks the value of two hidden text values which I set in the loop based on the params. I then append it to the H1.entry-title on document load. Possibly not the best way of doing this, but I'm no JS expert.

LOOP:

<span class="mrg-cat" style="display:none;">[wpv-search-term param="c"]</span>
<span class="mrg-search" style="display:none;">[wpv-search-term param="wpv_post_search"]</span>

LOOP JS:

$( document ).ready(function() {
  if ($('.mrg-cat').text() != null && $('.mrg-cat').text() != '' && $('.mrg-cat').text() != '0') {
  	$('.entry-title').append(': ' + $('.mrg-cat').text());
  } else if ($('.mrg-search').text() != null && $('.mrg-search').text() != '' && $('.mrg-search').text() != '0') {
  	$('.entry-title').append(': searching "' + $('.mrg-search').text() + '"');
  }
}); 

Thanks,
Chris

#1201721

Hi Chris,

Thank you for waiting.

Shane will be away for a few days and I'll be following up on his tickets.

I understand that you'd like to get the title of the taxonomy term, based on its slug value.

For this, "get_term_by" function can be used inside a custom shortcode:
https://codex.wordpress.org/Function_Reference/get_term_by

You can include the following custom shortcode, in your active theme's "functions.php" file:


// shortcode to get the tax term info
add_shortcode('get_tax_title_by_slug', 'get_tax_title_by_slug_fn');
function get_tax_title_by_slug_fn($atts) {

	$field = $atts['field'];
	$value = $atts['value'];
	$taxonomy = $atts['taxonomy'];

	$result = get_term_by( $field, $value, $taxonomy );
	if ($result)
	{
		return($result->name);
	}

}

In your view, where you have:


<span class="mrg-cat" style="display:none;">[wpv-search-term param="c"]</span>

You can update it to use this new shortcode, like this:


<span class="mrg-cat" style="display:none;">[get_tax_title_by_slug field="slug" value="[wpv-search-term param='c']" taxonomy="service"]</span>

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

Note: For a new question/concern, please open a new ticket.

regards,
Waqar

#1201725

My issue is resolved now. Thank you to Wagar and Shane for your help in resolving this.