Hello,
I am getting the following error, when trying to preview draft posts in the WP administration:
Warning: array_filter() expects parameter 1 to be array, bool given in /home/customer/www/…/public_html/wp-content/plugins/td-cloud-library/state/single/tdb_state_single.php on line 940
Fatal error: Uncaught TypeError: Argument 1 passed to tdb_state_single::sort_terms_hierarchically() must be of the type array, null given, called in /home/customer/www/…/public_html/wp-content/plugins/td-cloud-library/state/single/tdb_state_single.php on line 944 and defined in /home/customer/www/…/public_html/wp-content/plugins/td-cloud-library/state/single/tdb_state_single.php:3618 Stack trace: #0 /home/customer/www/…/public_html/wp-content/plugins/td-cloud-library/state/single/tdb_state_single.php(944): tdb_state_single->sort_terms_hierarchically(NULL, Array) #1 /home/customer/www/…/public_html/wp-content/plugins/td-cloud-library/shortcodes/single/tdb_single_categories.php(328): tdb_state_single->{closure}(Array) #2 /home/customer/www/…/public_html/wp-content/plugins/td-cloud-library/shortcodes/single/tdb_single_categories.php(328): Closure->__invoke(Array) #3 /home/customer/www/…/public_html/wp-content/plugins/td-composer/legacy/common/wp_booster/td_glo in /home/customer/www/…/public_html/wp-content/plugins/td-cloud-library/state/single/tdb_state_single.php on line 3618
It seems to be connected with the code I’ve added to functions.php in order to hide the names of three specific categories. (I did try ti use the option HIDE CATEGORY ON POST AND ON CATEGORY PAGES in the Newspaper theme panel, but it works only for the first category.)
add_filter('get_the_terms', 'hide_categories_terms', 10, 3);
function hide_categories_terms($terms, $post_id, $taxonomy){
// define which category IDs you want to hide
$excludeIDs = array(1, 2, 3);
// get all the terms
$exclude = array();
foreach ($excludeIDs as $id) {
$exclude[] = get_term_by('id', $id, 'category');
}
// filter the categories
if (!is_admin()) {
foreach($terms as $key => $term){
if($term->taxonomy == "category"){
foreach ($exclude as $exKey => $exTerm) {
if($term->term_id == $exTerm->term_id) unset($terms[$key]);
}
}
}
}
return $terms;
}
Theme name: Newspaper
Theme version: 12.6.3
Theme database version: 12.6.3
max_execution_time: 120
max_input_vars: 3000
WP Memory Limit: 512 MB/request
Caching plugin: No caching plugin detected
WP version: 6.4.3
WP multisite enabled: No