• incoe

    (@incoe)


    Hello,

    i get Notice: Undefined variable: i on line 19 which reference to this code

    <?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) == 0) : $wp_query->next_post(); else : the_post(); ?>

    any ideas how to fix that?

    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Try;

    <?php
     $i = 0;
     if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) == 0) : $wp_query->next_post(); else : the_post();
    ?>

    You may want to change the zero to one.

    Thread Starter incoe

    (@incoe)

    Thanks @andrew works fine with 0, when i put 1 it repeats post number 2 twice.

    Thanks for your help 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Notice: Undefined variable: i in debug mode’ is closed to new replies.