Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. $cats = get_the_category();
  2. $cat_id = $cat_id[0];
  3.  
  4. $category_posts = new WP_Query('cat=' . $cat_id->cat_ID);
  5. $all_tags = array();
  6. while ( $category_posts->have_posts() ) : $category_posts->the_post();
  7. $tags = wp_get_post_terms(get_the_ID(), 'post_tag');
  8.  
  9. foreach($tags as $tag)
  10. $all_tags[$tag->term_id][] = get_the_ID();
  11.  
  12. endwhile;
  13.  
  14. foreach($all_tags as $key => $tag) {
  15.  
  16. $term = get_term($key, 'post_tag');
  17. echo $term->name . '<BR>';
  18. foreach($tag as $post_id) {
  19. echo '<a href="' . get_permalink($post_id) . '">'. get_the_title($post_id) . "</a><BR>";
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement