Please install and activate the supplied child theme, inside the child theme functions.php
file paste this:
/* PORTFOLIO RELATED POSTS
================================================== */
function sf_portfolio_related_posts( $post_id, $item_count = 3 ) {
$query = new WP_Query();
$terms = wp_get_object_terms( $post_id, 'portfolio-category' );
if ( count( $terms ) ) {
$post_ids = array();
$term_categories = array();
foreach ($terms as $term) {
$term_categories[] = $term->term_id;
$term_objects = get_objects_in_term( $term->term_id, 'portfolio-category' );
foreach ($term_objects as $object) {
$post_ids[] = $object;
}
}
foreach (array_keys($post_ids, $post_id) as $key) {
unset($post_ids[$key]);
}
$args = array(
'post_type' => 'portfolio',
'post__in' => $post_ids,
'posts_per_page' => $item_count
);
$query = new WP_Query( $args );
}
// Return our results in query form
return $query;
}