<!-- begin custom related loop -->
 <h2 class="related-posts-heading2">Related Work</h2>
 <div class="related-border2"></div>
<?php
 
// get the custom post type's taxonomy terms
 
$custom_taxterms = wp_get_object_terms( $post->ID, 'tagportifolio', array('fields' => 'ids') );
// arguments
$args = array(
'post_type' => 'project',
'post_status' => 'publish',
'posts_per_page' => 4, // you may edit this number
'orderby' => 'rand',
'tax_query' => array(
    array(
        'taxonomy' => 'tagportifolio',
        'field' => 'id',
        'terms' => $custom_taxterms
    )
),
'post__not_in' => array ($post->ID),
);
$related_items = new WP_Query( $args );
// loop over query
if ($related_items->have_posts()) :
echo '<ul>';
while ( $related_items->have_posts() ) : $related_items->the_post();
?>


  
	                        <div class="related-posts-container2">
	                        <div class="related-posts-main2">
							<div class="related-posts-fade2">
							<div class="port-thumb"><div class="related-posts2">
							<a href="<?php the_permalink() ?>"> <?php the_post_thumbnail('portoflio-related-thumb'); ?></a></div></div></div>
							
					
						
				
						 
						 </div>
						 </div>
<?php
endwhile;
echo '</ul>';
endif;
// Reset Post Data
wp_reset_postdata();
?>
 
 
<!-- end custom related loop -->
