サポート » 使い方全般 » 一覧でのエラー文

  • 解決済 shinichi_ntrue

    (@shinichi_ntrue)


    トップページの一覧で一部広告表示を考えており表示はできたのですが、エラー文が表示されます。
    Notice: Undefined variable: loop_count in

    <?php query_posts("ignore_sticky_posts=1&posts_per_page=10&paged=$paged"); ?>
    				<?php echo '<div id="list">'; while ( have_posts() ): the_post(); $loop_count++; ?>
    				<?php if(!is_sticky()): ?>
    					<?php get_template_part('contents'); ?>
    				<?php endif; ?>
    <?php if ( $loop_count == 5 ) : ?>
    <?php if(wp_is_mobile()): ?><?php dynamic_sidebar( 'ad' ) ;?><?php endif; ?>
    <?php endif; ?>

    $loop_count++;と<?php if ( $loop_count == 5 ) : ?>~<?php endif; ?>が追記した箇所となります。
    お手数ですが、ご教授頂けると幸いです。

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

    (@rocketmartue)

    $loop_count のスタートの値が設定されていなからだと思います。

    while ( have_posts() ):の前に$loop_count = 0を追記してみてください。

    トピック投稿者 shinichi_ntrue

    (@shinichi_ntrue)

    Rocket Martueさん回答ありがとうございます。
    エラー文が消えました。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック「一覧でのエラー文」には新たに返信することはできません。