liatG
Support threads created in the last 30 days: 0
Favorite Forum Topics
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
Help creating a nested view of taxonomy terms to display on archive page sidebar
1
2
Started by: liatG
in: Toolset Professional Support
Problem: I would like to create a hierarchical menu of taxonomy term links. Solution: Use multiple nested Views of this taxonomy. Filter these Views by term ID or term parent, and output the term links and/or another nested View in each Loop. function n_level_term_id_func($atts) { $a = shortcode_atts( array( 'n' => '0' ), $atts ); $id = 0; $current_taxonomy = isset(get_queried_object()->taxonomy) ? get_queried_object()->taxonomy : null; if( $current_taxonomy == 'book-tax' ) { $ancestors = get_ancestors( get_queried_object()->term_id, $current_taxonomy ); $count = count( $ancestors ); $id = isset( $ancestors[ $count - $a['n'] ] ) ? $ancestors[ $count - $a['n']] : get_queried_object()->term_id; } return $id; } add_shortcode("n-level-term-id", "n_level_term_id_func"); Register this shortcode in third-party shortcode arguments, then you can use it as a term ID filter for any View: [wpv-view name="your-view-slug" terms="[n-level-term-id n='2']"] Relevant Documentation: |
4 | 21 | 6 years, 3 months ago |