function get_tags_in_cat( $cat_id ) { $posts = get_posts( array( 'category' => $cat_id, 'numberposts' => -1 ) ); $tags = array(); foreach ( $posts as $post ) { $post_tags = get_the_tags( $post->ID ); if ( ! empty( $post_tags ) ) foreach ( $post_tags as $tag ) $tags[ $tag->term_id ] = $tag->name; } asort( $tags ); return $tags; }
Show category tags WordPress. Code example
Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators
More
lil-code© | 2022 - 2024
Go Top