Show category tags WordPress. Code example open

Show category tags WordPress. Code example

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators
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;
}
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation