• Resolved Stefan

    (@stefan83)


    Hi I’m trying to assign different classes to 2 div in the loop (custom-posts-left to the first div and custom-post-right to the second). I can’t get the following to work, it only assigns custom-post-left to both. Any ideas?

    Thanks

    https://pastebin.com/86Gu5LrH

Viewing 2 replies - 1 through 2 (of 2 total)
  • Gwythan

    (@kevin-ashbridge)

    You condition “if (!($i%1))” will always return true, so it will never see the $i%2 condition. Try reversing the logic here, doing mod 2 first:

    if (!($i%2)) {
    echo ‘custom-posts-right’
    } else {
    echo ‘custom-posts-left’;
    }

    Thread Starter Stefan

    (@stefan83)

    Gotcha! Thanks very much, Kevin!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different classes for 2 divs in the loop’ is closed to new replies.