指定していないsidebar.phpを読み込んでしまう
-
はじめまして。
ほぼ初心者なのですが、クラウドテンプレートさんのテンプレートテーマを
カスタマイズして利用しています。TOPページ(front-page.php)のカスタマイズなのですが、
元のコードから、「最新投稿」を4つ並べている部分を削除すると
なぜか、「お知らせ」欄の下に、sidebar.phpの内容が表示されてしまいます。削除した部分を戻すと、sidebar.phpの内容も消えますので
ここに原因があるのはわかるのですが、理由と解決方法がわかりません。初心者で申し訳ないのですが、どなたかご教示いただけませんか。
よろしくお願いします。元のコードはこちらです。
———————
<?php get_header(); $header_image = get_header_image(); if ($header_image):?> <div id="mainImg"><img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="<?php bloginfo( 'description' ); ?>"></div><?php endif;?> <div id="wrapper"> <div id="content"> <?php cTpl_016_pc_red_sidebarBanner(); ?> <section> <?php if ( have_posts()) : the_post(); ?> <article id="post-<?php the_ID(); ?>" class="content"> <header> <h2 class="title"><span><?php the_title(); ?></span></h2> </header> <div class="post toppage"> <?php the_content();?> </div> </article> <?php endif; ?> <?php query_posts($query_string . "showposts=4&cat=-" .(get_category_by_slug('info')->term_id)); ?> <?php if (have_posts()) :?> <h2 class="title"><span>最新投稿</span></h2> <ul class="post"> <?php while (have_posts()) : the_post(); ?> <li> <?php echo get_the_post_thumbnail($post->ID, 'size1'); ?> <h3><?php the_title(); ?></h3> <?php the_excerpt();?> <p class="readon"><a href="<?php the_permalink() ?>">続きを読む...</a></p> <?php endwhile; ?> </ul> <?php else: ?> <?php endif; ?> <?php $posts = get_posts('category_name=info&numberposts=5');?> <?php if ($posts):?> <div class="newsTitle"> <h3 class="title"><span>お知らせ</span></h3> <p><a href="<?php echo esc_url( home_url( '/' ) ); ?>category/info/">一覧</a> </div> <div class="widgetWrap"> <section class="widgetInfo"> <div class="news"> <?php foreach($posts as $post) : setup_postdata($post)?> <p><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><time datetime="<?php the_time('Y-m-d')?>"><?php the_time("Y/n/j"); ?></time><span><?php the_title(); ?></span></a> <?php endforeach;?> </div> </section> </div> <?php endif;?> </section> <?php get_footer(); ?>———————
削除した部分
<?php query_posts($query_string . "showposts=4&cat=-" .(get_category_by_slug('info')->term_id)); ?> <?php if (have_posts()) :?> <h2 class="title"><span>最新投稿</span></h2> <ul class="post"> <?php while (have_posts()) : the_post(); ?> <li> <?php echo get_the_post_thumbnail($post->ID, 'size1'); ?> <h3><?php the_title(); ?></h3> <?php the_excerpt();?> <p class="readon"><a href="<?php the_permalink() ?>">続きを読む...</a></p> <?php endwhile; ?> </ul> <?php else: ?> <?php endif; ?>
トピック「指定していないsidebar.phpを読み込んでしまう」には新たに返信することはできません。