Guest User

Untitled

a guest
May 15th, 2015
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. <?php
  2.     $args = array(
  3.         'post_type' => 'produkty',
  4.         'meta_key' => 'produkt_nowosc',
  5.         'meta_value' => 'tak',
  6.         'posts_per_page' => -1
  7.     );
  8.  
  9.     $query = new WP_Query($args);  
  10.     $q = array();
  11.  
  12.     while ( $query->have_posts() ) {
  13.         $query->the_post();
  14.         $a = '<a href="'. get_permalink() .'">' . get_the_title() .'</a>';
  15.         $terms = wp_get_post_terms( $post->ID, 'kategorie_produktow', $args );
  16.         foreach ( $terms as $term) {
  17.             $term_link = get_term_link( $term );
  18.             $b = '<span>'.$term->name.'</span>';    
  19.         }
  20.         $q[$b][] = $a;
  21.     }
  22.     wp_reset_postdata();
  23.     foreach ($q as $key=>$values) {
  24.         echo $key;
  25.         echo '<ul>';
  26.             foreach ($values as $value){
  27.                 echo '<li>' . $value . '</li>';
  28.             }
  29.         echo '</ul>';
  30.     }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment