Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $custom_taxterms = wp_get_object_terms($post->ID, array ('klockor','smycken'), array('fields' => 'ids') );
- // arguments
- $args = array(
- 'post_type' => 'varumarken',
- 'post_status' => 'publish',
- 'posts_per_page' => 5, // you may edit this number
- 'orderby' => 'rand',
- 'tax_query' => array(
- 'relation' => 'OR',
- array(
- 'taxonomy' => 'klockor',
- 'field' => 'id',
- 'terms' => $custom_taxterms
- ),
- array(
- 'taxonomy' => 'smycken',
- 'field' => 'id',
- 'terms' => $custom_taxterms
- )
- ),
- 'post__not_in' => array ($post->ID),
- );
- $related_items = new WP_Query( $args );
- if ( $related_items->have_posts() ) :
- while ( $related_items->have_posts() ) : $related_items->the_post();
- // post stuff here
- endwhile;
- endif;
- wp_reset_postdata();
Add Comment
Please, Sign In to add comment