Advertisement
Guest User

Untitled

a guest
Mar 27th, 2012
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <?php
  2. if(is_category()){
  3.  
  4. $object = get_queried_object();
  5.  
  6. global $wp_query;
  7. if($wp_query->post_count > 0) {
  8. if(!empty($wp_query->posts)){
  9.  
  10. $post_cats = array();
  11. foreach($wp_query->posts as $catpost){
  12. $post_categories = wp_get_post_categories( $catpost->ID );
  13. foreach($post_categories as $c){
  14. if($c != $object->term_id){
  15. $post_cats[] = $c;
  16. }
  17. }
  18. }
  19.  
  20. if(!empty($post_cats)) {
  21. $post_cats = array_unique($post_cats);
  22. $catstring = '';
  23. foreach ($post_cats as $cats) {
  24. $catstring .= $cats . ',';
  25. }
  26. $catstring = trim($catstring, ', ');
  27. wp_list_categories('include='.$catstring);
  28. }
  29. }
  30. }
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement