
cat tag link
By:
alchymyth on
Jun 17th, 2011 | syntax:
PHP | size: 0.80 KB | hits: 210 | expires: Never
<?php
if( is_category() ) :
$cat_id = get_query_var('cat');
query_posts('posts_per_page=-1&cat='.$cat_id);
if (have_posts()) :
$posttags = array(); $the_tags = array();
while (have_posts()) : the_post();
$tags = get_the_tags($post->ID);
if( $tags ){
foreach( $tags as $tag ) {
$posttags[] = $tag->term_id;
};
}
endwhile;
$slug = get_category($cat_id)->slug;
$posttags = array_unique( $posttags );
foreach( $posttags as $tag ) {
$tag = get_tag($tag);
$the_tags[] = '<a href ="' . get_bloginfo('wpurl') . '/?category_name=' . $slug . '&tag=' . $tag->slug . '">' . $tag->name . '</a>';
}
sort($the_tags); //sort optional
if( $the_tags ) {
echo '<ul><li>' . implode("</li>\n<li>", $the_tags) . '</li></ul>';
}
endif; wp_reset_query();
endif;
?>