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

all tags for a category in a linked list

By: alchymyth on Apr 14th, 2011  |  syntax: PHP  |  size: 0.67 KB  |  views: 150  |  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.         query_posts('category_name=work');
  3.         if (have_posts()) : while (have_posts()) : the_post();
  4.         $posttags = get_the_tags();
  5.                 if ($posttags) {
  6.                         foreach($posttags as $tag) {
  7.                                 $all_tags_arr[] = $tag->term_id; //USING JUST $tag MAKING $all_tags_arr A MULTI-DIMENSIONAL ARRAY, WHICH DOES WORK WITH array_unique
  8.                         }
  9.                 }
  10.         endwhile; endif; wp_reset_query();
  11.  
  12.         $tags_arr = array_unique($all_tags_arr); //REMOVES DUPLICATES
  13.         //echo '<pre>'.print_r($tags_arr, true).'</pre>'; //OUTPUT FINAL TAGS FROM CATEGORY
  14.  
  15. echo '<ul>';
  16. foreach ($tags_arr as $tag) {
  17. echo '<li><a href="' . get_tag_link($tag) . '">' . get_tag($tag)->name . '</a></li>';
  18. }
  19. echo '</ul>';
  20.  
  21. ?>