breadcrumbs PRIMARY
-
hi
I have a code to set breadcrumbs with higher priority
I want to add a condition to it
If SELECT PRIMARY was empty
Run this codeadd_filter( 'aioseo_breadcrumbs_output', 'aioseo_breadcrumbs_output_start' ); function aioseo_breadcrumbs_output_start( $display ) { if ( ! is_singular( 'post' ) ) { return $display; } add_filter( 'wp_get_object_terms', 'aioseo_breadcrumbs_trail_change_term' ); return $display; } function aioseo_breadcrumbs_trail_change_term( $terms ) { remove_filter( 'wp_get_object_terms', 'aioseo_breadcrumbs_trail_change_term' ); $hasArticlesTerm = current( wp_list_filter( $terms, [ 'slug' => 'game' ] ) ); if ( ! empty( $hasArticlesTerm ) ) { foreach ( $terms as $key => $term ) { if ( ( 0 === $term->parent && $term->term_id !== $hasArticlesTerm->term_id ) || ( 0 < $term->parent && $term->parent !== $hasArticlesTerm->term_id ) ) { unset( $terms[ $key ] ); } } } return $terms; }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘breadcrumbs PRIMARY’ is closed to new replies.