Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $args = array(
- 'post_type' => 'produkty',
- 'meta_key' => 'produkt_nowosc',
- 'meta_value' => 'tak',
- 'posts_per_page' => -1
- );
- $query = new WP_Query($args);
- $q = array();
- while ( $query->have_posts() ) {
- $query->the_post();
- $a = '<a href="'. get_permalink() .'">' . get_the_title() .'</a>';
- $terms = wp_get_post_terms( $post->ID, 'kategorie_produktow', $args );
- foreach ( $terms as $term) {
- $term_link = get_term_link( $term );
- $b = '<span>'.$term->name.'</span>';
- }
- $q[$b][] = $a;
- }
- wp_reset_postdata();
- foreach ($q as $key=>$values) {
- echo $key;
- echo '<ul>';
- foreach ($values as $value){
- echo '<li>' . $value . '</li>';
- }
- echo '</ul>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment