Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(is_category()){
- $object = get_queried_object();
- global $wp_query;
- if($wp_query->post_count > 0) {
- if(!empty($wp_query->posts)){
- $post_cats = array();
- foreach($wp_query->posts as $catpost){
- $post_categories = wp_get_post_categories( $catpost->ID );
- foreach($post_categories as $c){
- if($c != $object->term_id){
- $post_cats[] = $c;
- }
- }
- }
- if(!empty($post_cats)) {
- $post_cats = array_unique($post_cats);
- $catstring = '';
- foreach ($post_cats as $cats) {
- $catstring .= $cats . ',';
- }
- $catstring = trim($catstring, ', ');
- wp_list_categories('include='.$catstring);
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement