I am looking to get a nested loop working which will display 6 posts having a certain code, go back, display exactly the same 6 posts having a different code after which continue this until you will find forget about posts.
A B C D E F a b c d e f G H I J K L g h i j k l
To date I have handled to locate this code:
however it only repeats the loop around the first 6 posts and, later on, it really results the posts once.
Most likely the 2nd output is not nested properly into the first, can anybody assist me to figure this out?
In my opinion you need to simply totally reset your count = once you discover that count = 6
// If count is equal to 6 if( $count == 6 ) : //reset my counter count = 0; // Second query $my_second_query = new WP_Query; $my_second_query->query( array( 'posts_per_page' => '6' ) );
Try altering line 27 to make use of modulo % operator or fmod function rather than if($count == 6 )
Which should give your the expected result for those products within the list by repeating this course of action for each publish 6 at any given time (6,12,18,24,...).
if($count % 6 ==0 && $count !=0) // should give you what you are looking for example of modulo and fmod use <?php $var1 = 5; $var2 = 2; echo $var1 % $var2; //Returns 1 echo fmod($var1,$var2); //Also returns the same ?>