Skip Navigation

[Resolved] When a website has many taxonomy terms, views editor screens crash

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

Last updated by Minesh 1 year, 6 months ago.

Assisted by: Minesh.

Author
Posts
#2603877

On a client site, 25k + terms are in a (WC Product) taxonomy.
Whenever we attempt to edit a view that lists products, the view editor crashes. It never finishes to load, and (safari) will tell you the site has a problem and needs to reload (endless loop thereafter)

I found, that the reason seems to be that View tries to load all 25K terms in the taxonomy filters (those checkboxes that let you select either term to show products in)

Is there some way to disable that on specific views?
As this is not a front end issue, but backend issue, I couldn't find any API for it

#2604003

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Hi Beda, Hope you are doing great!!

Fetching 25k + terms its too much even without Toolset. Even we try to fetch couple of thousand items it will become slow.

Please allow me to test few hooks and I'll get back to you as soon as possible latest by tomorrow EOD.

#2604423

Minesh
Supporter

Languages: English (English )

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

Hi Beda,

I've escalated the issue to our next level support to check if there is any concrete solution available for this issue. Please hold on for further update.

#2604687

Minesh
Supporter

Languages: English (English )

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

Hi Beda,

Finally we found at lease a hook that we can share and using that you can limit the terms in the backend for your taxonomy filter:

You can try to use the following filter code:

add_filter( 'wpv_filter_taxonomy_frontend_search_get_terms_args', function( $get_terms_args, $taxonomy ){

	if ( !defined('REST_REQUEST') && !is_admin() ) {
		// a regular front-end request >> do nothing
		return $get_terms_args;		
	}

	if ( defined('REST_REQUEST') || is_admin() ) {
		// a regular back-end request, or back-end preview REST request
		
		if ( $taxonomy == 'gym-type' ) {
			$get_terms_args['number'] = 1;     /// edit how many options you want to show 1/5/10
		}
	}
	
	return $get_terms_args;
}, 10, 2);

Where:
- Replace 'gym-type' with your original taxonomy slug.
- using above code it will display 1 option for the filter as we passed 1 to $get_terms_args['number'] argument.

Note:
- this applies universally to back-end previews as the View ID is not available in the REST requests