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