SHOW:
|
|
- or go back to the newest paste.
| 1 | - | $custom_taxterms = wp_get_object_terms( $post->ID,array ('klockor','smycken'), array('fields' => 'ids') );
|
| 1 | + | $custom_taxterms = wp_get_object_terms($post->ID, array ('klockor','smycken'), array('fields' => 'ids') );
|
| 2 | // arguments | |
| 3 | $args = array( | |
| 4 | 'post_type' => 'varumarken', | |
| 5 | 'post_status' => 'publish', | |
| 6 | 'posts_per_page' => 5, // you may edit this number | |
| 7 | 'orderby' => 'rand', | |
| 8 | 'tax_query' => array( | |
| 9 | 'relation' => 'OR', | |
| 10 | array( | |
| 11 | 'taxonomy' => 'klockor', | |
| 12 | 'field' => 'id', | |
| 13 | 'terms' => $custom_taxterms | |
| 14 | ), | |
| 15 | array( | |
| 16 | 'taxonomy' => 'smycken', | |
| 17 | 'field' => 'id', | |
| 18 | 'terms' => $custom_taxterms | |
| 19 | ) | |
| 20 | ||
| 21 | ), | |
| 22 | 'post__not_in' => array ($post->ID), | |
| 23 | - | $related_items = new WP_Query( $args ); ?> |
| 23 | + | |
| 24 | ||
| 25 | $related_items = new WP_Query( $args ); | |
| 26 | if ( $related_items->have_posts() ) : | |
| 27 | while ( $related_items->have_posts() ) : $related_items->the_post(); | |
| 28 | // post stuff here | |
| 29 | endwhile; | |
| 30 | endif; | |
| 31 | wp_reset_postdata(); |