single.phpの<関連記事>の該当箇所を
以下の様にごっそり変えて下さい
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
<!--関連記事--> <h4 class="kanren">関連記事</h4> <div class="sumbox02"> <div id="topnews"> <div> <?php $categories = get_the_category($post->ID); $category_ID = array(); foreach($categories as $category): array_push( $category_ID, $category -> cat_ID); endforeach ; $args = array( 'post__not_in' => array($post -> ID), 'posts_per_page'=> 5, 'category__in' => $category_ID, 'orderby' => 'rand', ); $st_query = new WP_Query($args); ?> <?php if( $st_query -> have_posts() ): ?> <?php while ($st_query -> have_posts()) : $st_query -> the_post(); ?> <dl><dt> <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"> <?php if ( has_post_thumbnail() ): // サムネイルを持っているときの処理 ?> <?php echo get_the_post_thumbnail($post->ID, 'thumb110'); ?> <?php else: // サムネイルを持っていないときの処理 ?> <img src="<?php echo get_template_directory_uri(); ?>/images/no-img.png" alt="no image" title="no image" width="110px" /> <?php endif; ?> </a> </dt> <dd> <h4 class="saisin"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> <p class="basui"> <?php echo mb_substr(strip_tags(akita_noshotcode($post-> post_content)),0,35).'...'; ?></p> <p class="motto"><a href="<?php the_permalink(); ?>">記事を読む</a></p> </dd></dl> <?php endwhile; ?> <?php else: ?> <p>記事はありませんでした</p> <?php endif; wp_reset_postdata(); ?> </div> </div> </div> <!--/関連記事--> |