Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <h2>Final test</h2>
  2.  
  3. <?php
  4. $cat_id = $category->cat_ID;
  5. global $post;
  6. $category_posts = new WP_Query('cat=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.  
  12. foreach($tags as $tag)
  13. $all_tags[$tag->term_id][] = get_the_ID();
  14. var_dump($tags);
  15. endwhile;
  16.  
  17. foreach($all_tags as $key => $tag) {
  18. $term_id = get_term($key);
  19. $term = get_term($term_id, 'post_tag');
  20. echo $term->name . '<BR>';
  21. foreach($tag as $post_id) {
  22. echo '<a href="' . get_permalink($post_id) . get_the_title($post_id) . "></a><BR>";
  23. }
  24.  
  25. }
  26.  
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement