フォーラムへの返信

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック投稿者 taroken

    (@taroken)

    ご回答ありがとうございます。
    投稿記事を表示するループの最後にwp_reset_query()を追加してみました。

    <?php query_posts('&cat=-7&ignore_sticky_posts=1');
    if (have_posts()) :while (have_posts()) : the_post(); ?>
    
    〜記事を表示〜
    
    <?php endwhile; endif; wp_reset_query(); ?>

    しかし、やはりサイドバーに表示している「最近の記事」「カテゴリー別まとめ」「月別まとめ」が機能しないままでした。
    機能しないというのを具体的に申しますと以下の通りです。

    ・先頭記事からそのまま順に読み込まれしまう。
    ・次の記事へのリンクが表示されていない。
    ・コメントフォームが表示されてしまう。

    これはアーカイブ関連ページへ移動するための条件が作動していないということでしょうか。

    トピック投稿者 taroken

    (@taroken)

    ご回答ありがとうございます。

    お教えいただいたようにやってみたのですが反映されませんでした。

    色々試してみたのですが、

    <?php query_posts('&cat=-7&ignore_sticky_posts=1');
      if (have_posts()) :while (have_posts()) : the_post(); ?>

    こうすると2つの条件が反映されました。
    …ただそうすると今度はサイドバーに表示している「最近の記事」「カテゴリー別まとめ」「月別まとめ」が同じページを読み込むようになり機能しなくなってしまいました。

    index.phpとsidebar.phpの全コードは以下の通りです。

    index.php

    <?php get_header(); ?>
    
    <div id="blogbox" class="clearfix">
    
    <div id="content">
      <?php query_posts($query_string . "&ignore_sticky_posts=1&cat=-7"); ?>
      <?php if(have_posts()): while(have_posts()):
      the_post(); ?>
    
      <div class="post">
        <h2><a href="<?php the_permalink(); ?>">
          <?php the_title(); ?></a></h2>
        <?php the_content(); ?>
        <p class="postinfo">
          <?php echo get_the_date(); ?> <?php the_time(); ?>
          |
          カテゴリー:<?php the_category(', '); ?>
          |
          <a href="<?php comments_link(); ?>">コメント
            <?php comments_number('(0)', '(1)', '(%)'); ?>
          </a>
        </p>
      <!--post--></div>
    
      <?php if(is_single()): ?>
      <p class="pagelink">
        <span class="oldpage">
          <?php previous_post_link(); ?>
        </span>
        <span class="newpage">
          <?php next_post_link(); ?>
        </span>
      </p>
      <?php endif; ?>
    
      <?php endwhile; endif; ?>
    
      <?php if(is_home()): ?>
      <p class="pagelink">
        <span class="oldpage">
          <?php next_posts_link('« 古い記事'); ?>
        </span>
        <span class="newpage">
          <?php previous_posts_link('新しい記事 »'); ?>
        </span>
      </p>
      <?php endif; ?>
    
      <?php if(is_archive()): ?>
      <p class="pagelink">
        <span class="oldpage">
          <?php next_posts_link('« 古い記事'); ?>
        </span>
        <span class="newpage">
          <?php previous_posts_link('新しい記事 »'); ?>
        </span>
      </p>
      <?php endif; ?>
    
      <?php comments_template(); ?>
    
    <!--content--></div>
    
      <div id="sidebar">
    
      <ul>
        <?php get_sidebar(); ?>
      </ul>
    
      <p class="feed">
        <img src="<?php bloginfo('template_url'); ?>/images/feed-icon-14x14.png" alt="*" width="14" height="14" />
        <a href="<?php bloginfo('rss2_url'); ?>">RSS FEED</a>
      </p>
    
    <!--sidebar--></div>
    
    <!--blogbox--></div>
    
    <?php get_footer(); ?>

    sidebar.php

    <div id="sidebar">
    
     <ul>
    
      <li>
       <h2 class="widgettitle">最近の記事</h2>
       <ul class="widget">
        <?php wp_get_archives('type=postbypost&limit=10&cat=-7&title_li='); ?>
       </ul>
      </li>
    
      <li>
       <h2 class="widgettitle">カテゴリー別まとめ</h2>
       <ul class="widget">
        <?php wp_list_categories('title_li=&exclude=7'); ?>
       </ul>
      </li>
    
      <li>
       <h2 class="widgettitle">月別まとめ</h2>
       <ul class="widget">
        <?php wp_get_archives('limit=10&cat=-7'); ?>
       </ul>
      </li>
     </ul>
    
    </div>

    よろしくお願い致します。

2件の返信を表示中 - 1 - 2件目 (全2件中)