I'm working on a modified wordpress loop where in it has an if and else condition inside. The code is down below.
What I'm trying to do is add a container that will hold every post that meets the condition. This will group each condition.
<div class="container">
<?php if (have_posts()) : ?>
<?php
$i = 1;
while (have_posts()) {
the_post();
// Add a DIV CONTAINER that holds the FIRST CONDITION
if ($i <= 3) {
the_title();
the_content();
// Add a DIV CONTAINER that holds the FIRST CONDITION
// Add a DIV CONTAINER that holds the SECOND CONDITION
} elseif ($i <= 9) {
the_title();
the_permalink();
// Add a DIV CONTAINER that holds the SECOND CONDITION
// Add a DIV CONTAINER that holds the THIRD CONDITION
} elseif ($i <= 13) {
the_title();
the_permalink();
// Add a DIV CONTAINER that holds the THIRD CONDITION
// Add a DIV CONTAINER that holds the FOURTH CONDITION
} elseif ($i <= 15) {
the_title();
// Add a DIV CONTAINER that holds the FOURTH CONDITION
// Add a DIV CONTAINER that holds the FIFTH CONDITION
} else {
the_title();
// Add a DIV CONTAINER that holds the FIFTH CONDITION
}
$i++;
}
?>
<?php else : ?>
<h2>No Posts Found</h2>
<?php endif; ?>
</div>
If I add an echo '<div class="FirstCondition">';where my comments are, this is what happens.

It only repeats the div container that I added. What I need is to add a simple DIV Container that HOLDS all posts that meet the criteria.
The final output would be like this:
<div class="FirstCondition">
Wordpress Published Post that meets the criteria for the First Condition
Wordpress Published Post that meets the criteria for the First Condition
Wordpress Published Post that meets the criteria for the First Condition
Wordpress Published Post that meets the criteria for the First Condition
</div>
<div class="SecondCondition">
Wordpress Published Post that meets the criteria for the Second Condition
Wordpress Published Post that meets the criteria for the Second Condition
Wordpress Published Post that meets the criteria for the Second Condition
Wordpress Published Post that meets the criteria for the Second Condition
</div>
<div class="ThirdCondition">
Wordpress Published Post that meets the criteria for the Third Condition
Wordpress Published Post that meets the criteria for the Third Condition
Wordpress Published Post that meets the criteria for the Third Condition
Wordpress Published Post that meets the criteria for the Third Condition
</div>
<div class="FourthCondition">
Wordpress Published Post that meets the criteria for the Fourth Condition
Wordpress Published Post that meets the criteria for the Fourth Condition
Wordpress Published Post that meets the criteria for the Fourth Condition
Wordpress Published Post that meets the criteria for the Fourth Condition
</div>
<div class="FifthCondition">
Wordpress Published Post that meets the criteria for the Fifth Condition
Wordpress Published Post that meets the criteria for the Fifth Condition
Wordpress Published Post that meets the criteria for the Fifth Condition
Wordpress Published Post that meets the criteria for the Fifth Condition
</div>
Is this possible? how? please help.
