ID); $related_post_title = alyssas_blog_get_option( 'you_may_like_title' ); $post_id = get_the_ID(); $cat_ids = array(); if(!empty($categories) && is_wp_error($categories)): foreach ($categories as $category): array_push($cat_ids, $category->term_id); endforeach; endif; $current_post_type = get_post_type($post_id); $query_args = array( 'category__in' => $cat_ids, 'post_type' => $current_post_type, 'post__not_in' => array($post->ID), 'posts_per_page' => 3, // Number of related posts that will be shown. 'ignore_sticky_posts'=> 1, 'orderby' => 'rand' ); $related_cats_post = new WP_Query( $query_args ); if($related_cats_post->have_posts()):?>