array( $the_post_id ), 'post_type' => 'post', 'post_status' => 'publish', 'no_found_rows' => true, 'ignore_sticky_posts' => true, 'posts_per_page' => $posts_per_page, 'orderby' => 'rand', ); if ( 'category' === $setting['post_relation_type'] ) { // カテゴリ情報から関連記事を呼び出す $categories = get_the_category( $the_post_id ); $cat_array = array(); foreach ( $categories as $the_cat ) { array_push( $cat_array, $the_cat->cat_ID ); } if ( ! empty( $cat_array ) ) { $related_args['category__in'] = $cat_array; } } else { // タグ情報から関連記事を呼び出す $tags = wp_get_post_tags( $the_post_id ); $tag_array = array(); foreach ( $tags as $the_tag ) { array_push( $tag_array, $the_tag->term_id ); } if ( ! empty( $tag_array ) ) { $related_args['tag__in'] = $tag_array; } } // WP_Query生成 $related_query = new WP_Query( apply_filters( 'arkhe_related_posts_args', $related_args ) ); // ループのカウント用変数 $loop_count = 0; ?>

have_posts() ) : ?>