| @@ -43,9 +43,11 @@ | ||
| 43 | 43 | $ancestors = []; |
| 44 | 44 | |
| 45 | 45 | if ( is_single() && ! empty( $_current_queried_object_id ) ) { |
| 46 | 46 | $_category_ids = wp_get_post_terms( get_the_ID(), 'doc_category', [ 'fields' => 'ids' ] ); |
| 47 | - $ancestors = get_ancestors( $_category_ids[0], 'doc_category' ); | |
| 47 | + if ( ! is_wp_error( $_category_ids ) && ! empty( $_category_ids ) ) { | |
| 48 | + $ancestors = get_ancestors( $_category_ids[0], 'doc_category' ); | |
| 49 | + } | |
| 48 | 50 | } |
| 49 | 51 | |
| 50 | 52 | if ( ! is_wp_error( $terms ) ) { |
| 51 | 53 | do_action_ref_array( 'betterdocs_layout_base_loop_start', [ & $terms, &$_defined_vars ] ); |
| @@ -59,8 +61,14 @@ | ||
| 59 | 61 | $docs_query_args = ! isset( $docs_query_args ) ? $_docs_query_args : wp_parse_args( $docs_query_args, $_docs_query_args ); |
| 60 | 62 | |
| 61 | 63 | $terms_count = count( $terms ); |
| 62 | 64 | $terms_number = 1; |
| 65 | + | |
| 66 | + $_term_ids = wp_list_pluck( $terms, 'term_id' ); | |
| 67 | + if ( ! empty( $_term_ids ) ) { | |
| 68 | + update_termmeta_cache( $_term_ids ); | |
| 69 | + } | |
| 70 | + | |
| 63 | 71 | foreach ( $terms as $term ) { |
| 64 | 72 | $_counts = betterdocs()->query->get_docs_count( |
| 65 | 73 | $term, |
| 66 | 74 | $nested_subcategory, |