Title: Loop ignoring variable
Last modified: January 17, 2019

---

# Loop ignoring variable

 *  Resolved [Chris Lowry](https://wordpress.org/support/users/medical-revision/)
 * (@medical-revision)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/loop-ignoring-variable/)
 * Trying to set up columns on my front page. Code is working fine for first colum
   but not on second column in the loop.
 * Full code here: [https://pastecode.xyz/view/6d734473](https://pastecode.xyz/view/6d734473)
 * But the basic issue is here:
 * `<?php if ($c==5 || $c==8){ echo "<div class='frontcolumn'>";}?>`
 * There’s a $c++ earlier on in the loop. A front column div is being generated 
   with the 5th post, but not the 8th one, and I can’t work it out!
 * Thanks for the help,
    C
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Floop-ignoring-variable%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [MaFt](https://wordpress.org/support/users/maft/)
 * (@maft)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/loop-ignoring-variable/#post-11100429)
 * Hard to say without seeing the site in action and being able to test but it could
   be the earlier line causing the issue:
 * `<?php if ($c==7 || $c==10){ echo "</div";}?>`
 * The end div isn’t being closed so the subsequent <div class=’frontcolumn’> may
   not be displaying correctly.
 * The PHP seems fine and seems to be working with regards to the values for $c 
   and the ‘frontcolumn’ div actually being generated in code.
 *  Thread Starter [Chris Lowry](https://wordpress.org/support/users/medical-revision/)
 * (@medical-revision)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/loop-ignoring-variable/#post-11101157)
 * Ha, came to post this reply back in here, and [@maft](https://wordpress.org/support/users/maft/)
   already beat me!

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

The topic ‘Loop ignoring variable’ is closed to new replies.

## Tags

 * [columns](https://wordpress.org/support/topic-tag/columns/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [Chris Lowry](https://wordpress.org/support/users/medical-revision/)
 * Last activity: [7 years, 4 months ago](https://wordpress.org/support/topic/loop-ignoring-variable/#post-11101157)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
