Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

cat tag link

By: alchymyth on Jun 17th, 2011  |  syntax: PHP  |  size: 0.80 KB  |  views: 217  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. if( is_category() ) :
  3. $cat_id = get_query_var('cat');
  4. query_posts('posts_per_page=-1&cat='.$cat_id);
  5.  if (have_posts()) :
  6.  $posttags = array(); $the_tags = array();
  7.  while (have_posts()) : the_post();
  8.    $tags = get_the_tags($post->ID);
  9.    if( $tags ){
  10.      foreach( $tags as $tag ) {
  11.      $posttags[] = $tag->term_id;
  12.      };
  13.    }
  14.  endwhile;
  15. $slug = get_category($cat_id)->slug;
  16.  $posttags = array_unique( $posttags );
  17.    foreach( $posttags as $tag ) {
  18.    $tag = get_tag($tag);
  19.    $the_tags[] = '<a href ="' . get_bloginfo('wpurl') . '/?category_name=' . $slug . '&tag=' . $tag->slug . '">' . $tag->name . '</a>';
  20.    }
  21.  sort($the_tags); //sort optional
  22.    if( $the_tags ) {
  23.    echo '<ul><li>' . implode("</li>\n<li>", $the_tags) . '</li></ul>';
  24.    }
  25.  endif; wp_reset_query();
  26. endif;
  27. ?>