I have different categories showing over main loop. I want to add a specific category post at even positions of main loop.
Example current post list with categories: cat1 cat1 cat1 cat1
required: cat1 catA cat1 catA cat1 catA cat1 catA
I am using this to skip present category post, but couldn't add the desired category post into its place.
<?php if($wp_query->current_post%2==1 && in_category('cat1')) continue; ?>
Being amateur with wp my knowledge is limited. How can I do it?
UPDATE: My logic is to use two loops on index.php, one with category and another excluding that category as this:
<?php for($y=0;$y<5;$y++) { ?>
<?php $off_num = ($paged-1)*5+$y; ?>
<?php if(is_home()) query_posts("posts_per_page=1&cat=-1&offset=$off_num"); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php if(is_home()) query_posts("posts_per_page=1&cat=-1,-10&offset=$off_num"); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; }?>
Altogether this code shows 10 posts, do I need to add wp_reset_query
or any other function like this? My Pagination too got messed up. Earlier their used to be 577 pages and now after this code, there are 2350 pages and those after 577 give 404 error.
How change I remove above problems?