$post_type, 'orderby' => $orderby, 'order' => $order, 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => $post_number, 'post__not_in' => array($post->ID)) ); break; case 'tag': $relateds = get_posts(array( 'post_type' => $post_type, 'orderby' => $orderby, 'order' => $order, 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => $post_number, 'post__not_in' => array($post->ID)) ); break; case 'category-service': $custom_taxterms = wp_get_object_terms( $post->ID, 'category-service', array('fields' => 'ids') ); // arguments $nbtargs = array( 'post_type' => 'service', 'post_status' => 'publish', 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => $post_number, // you may edit this number 'orderby' => 'rand', 'tax_query' => array( array( 'taxonomy' => 'category-service', 'field' => 'id', 'terms' => $custom_taxterms ) ), 'post__not_in' => array ($post->ID), ); $relateds = new WP_Query( $nbtargs ); break; default: $custom_taxterms = wp_get_object_terms( $post->ID, 'category-team', array('fields' => 'ids') ); // arguments $nbtargs = array( 'post_type' => 'team', 'post_status' => 'publish', 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => $post_number, // you may edit this number 'orderby' => 'rand', 'tax_query' => array( array( 'taxonomy' => 'category-team', 'field' => 'id', 'terms' => $custom_taxterms ) ), 'post__not_in' => array ($post->ID), ); $relateds = new WP_Query( $nbtargs ); break; } } $image_file_src = wp_get_attachment_image_src($image_file, ''); $attr = array(); if( !empty($image_file_src) ) { $attr = array( 'src' => $image_file_src[0], ); if(!empty($image_file_src[1])) $attr['width'] = $image_file_src[1]; if(!empty($image_file_src[2])) $attr['height'] = $image_file_src[2]; } if( function_exists('wp_get_attachment_image_srcset') ) { $attr['srcset'] = wp_get_attachment_image_srcset($image_file, $thumbsize); } if( !empty($alt) ) $attr['alt'] = $alt; ?>