Advertisement
Guest User

Untitled

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