$current_post, 'posts_per_page' => $related_item_number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'update_post_term_cache' => false, ); # Checking Related Posts Order ---------- if( wtbigshop_option( 'rt_post_related_sort' ) ){ $post_order = wtbigshop_option( 'rt_post_related_sort' ); if( $post_order == 'rand' ){ $args['orderby'] = 'rand'; } elseif( $post_order == 'views' ){ $args['orderby'] = 'meta_value_num'; } elseif( $post_order == 'popular' ){ $args['orderby'] = 'comment_count'; } elseif( $post_order == 'modified' ){ $args['orderby'] = 'modified'; $args['order'] = 'ASC'; } elseif( $post_order == 'recent' ){ $args['orderby'] = ''; $args['order'] = ''; } } # Get related posts by author ---------- if( $query_type == 'author' ){ $args['author'] = get_the_author_meta( 'ID' ); } # Get related posts by tags ---------- elseif( $query_type == 'tag' ){ $tags_ids = array(); $post_tags = get_the_terms( $post_id, 'post_tag' ); if( ! empty( $post_tags ) ){ foreach( $post_tags as $individual_tag ){ $tags_ids[] = $individual_tag->term_id; } $args['tag__in'] = $tags_ids; } }else{ $category_ids = array(); $categories = get_the_category( $post_id ); foreach( $categories as $individual_category ){ $category_ids[] = $individual_category->term_id; } $args['category__in'] = $category_ids; } # Get the posts ---------- $related_query = new \WP_Query( $args ); if( $related_query->have_posts() && wtbigshop_option( 'rt_post_related' ) ) { ?>
have_posts() ) { $related_query->the_post(); $meta_list = wtbigshop_option( 'rt_blog_meta', '', true ); ?>
>
', esc_url( get_permalink() ) ), '' ); if ( ! empty( $meta_list ) && wtbigshop_option( 'rt_meta_visibility' ) ) { echo wtbigshop_post_meta( [ 'with_list' => true, 'with_icon' => true, 'include' => $meta_list, 'author_prefix' => wtbigshop_option( 'rt_author_prefix' ), ] ); } ?>