wordpress - Display posts from the same child taxonomy as the current post -
i’m following tutorial
https://sridharkatakam.com/custom-wordpress-widget-showing-cpt-entries-categorycategories/
i have 2 custom taxonomies (events / centers), respective child taxonomies ( event1, event2… / center1, center2…
).
what should change display posts same child taxonomy current post? (one post can use 1 eventschild
taxonomy
, centers child taxonomy, or both.)
i want match taxonomy
, don’t use category.
what have use instead of these?
get_the_category() category_nicename
don’t mind if using method
https://sridharkatakam.com/show-posts-category-current-post/
very appreciate help!
<?php //first current term $current_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); //then set args wp_list_categories $args = array( 'child_of' => $current_term->term_id, 'taxonomy' => $current_term->taxonomy, 'hide_empty' => 0, 'hierarchical' => true, 'depth' => 1, 'title_li' => '' ); wp_list_categories( $args ); ?>
^^this how did donkey's years ago :)
Comments
Post a Comment