I'm currently working on a new WP theme.
I was working on my theme locally and it was working perfectly without any issues.
Since I moved the theme to my dev server, everything has worked except for the main loop on the home page.
My loop works perfectly in archive, date, category, tag, author and search pages which were created directly from the home template. The loop even works on paginated versions of the home page e.g. homeurl.com/page/2.
I have double checked the code and it is the same. If it works locally it should work on my dev server, too.
Here is the code for my loop, it is explained below:
<div class="contents__colone" id="contents__main">
<?php
$i = 0;
if (have_posts()) :
while(have_posts()) :
$i++;
if(($i % 2) == 0) {
$wp_query->next_post();
} else if ($page_number == 1 and ($i == 1 || $i == 2 || $i == 3)) {
$wp_query->next_post();
} else {
the_post();
get_template_part('article_preview');
}
endwhile;
endif;
$i = 0;
rewind_posts();
?>
</div>
<div class="contents__coltwo">
<?php
if (have_posts()) :
while(have_posts()) :
$i++;
if(($i % 2) !== 0) {
$wp_query->next_post();
} else if ($page_number == 1 and ($i == 1 || $i == 2 || $i == 3)) {
$wp_query->next_post();
} else {
the_post();
get_template_part('article_preview');
}
endwhile;
endif;
$i = 0;
?>
</div>
I have a carousel at the top that contains the first three posts. The reason for my unusual loop is that I have two columns which I populate with the page's posts whilst also excluding the carousel posts. So in each column I output every other post.
Again this loop works fine locally, but doesn't on the dev server.