Advertisement
deepbevel

filter cat and tag

Jan 31st, 2012
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <ul><?php
  2.  
  3. query_posts('category_name=uncategorized');
  4. if (have_posts()) : while (have_posts()) : the_post();
  5. $posttags = get_the_tags();
  6. if ($posttags) {
  7. foreach($posttags as $tag) {
  8. $all_tags_arr[] = $tag->term_id; //USING JUST $tag MAKING $all_tags_arr A MULTI-DIMENSIONAL ARRAY, WHICH DOES WORK WITH array_unique
  9. }
  10. }
  11. endwhile; endif; wp_reset_query();
  12.  
  13. $tags_arr = array_unique($all_tags_arr); //REMOVES DUPLICATES
  14. //echo '<pre>'.print_r($tags_arr, true).'</pre>'; //OUTPUT FINAL TAGS FROM CATEGORY
  15.  
  16. echo '<ul>';
  17. foreach ($tags_arr as $tag) {
  18. echo '<li><a href="' . get_tag_link($tag) . '">' . get_tag($tag)->name . '</a></li>';
  19. }
  20. echo '</ul>';
  21.  
  22. ?></ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement