jQuery - Counting images and then wrapping a certain amount
<p>Im using wordpress to develop a site ... im doing the template in a very custom way, what im doing is running my own query to get all the images from the wordpress backend.</p>

<p>What i have works perfect to display every one of them, but what i want to do is display 6 images normally, and then wrap all the rest in a div .. is this possible?</p>

<p>the code i have at the moment is as follows:</p>

<pre><code>$query = "SELECT * FROM wp_ngg_pictures WHERE galleryid = '1'";
$fp_banners = $wpdb-&gt;get_results($query, OBJECT);

foreach ($fp_banners as $banners):
    &lt;img src="/wp-content/gallery/frontpage/&lt;?php echo $banners-&gt;filename; ?&gt;" alt="image description" width="773" height="432" /&gt;
endforeach;
</code></pre>

<p>What i want to do is display the first 6 normally, and then any that are added after the first 6 to be wrapped in their own container, so for example, if i have added 8 images to the backend, the generated code will look like so</p>

<pre><code>&lt;img src="image.jpg" alt="image description" width="773" height="432" /&gt;
&lt;img src="image.jpg" alt="image description" width="773" height="432" /&gt;
&lt;img src="image.jpg" alt="image description" width="773" height="432" /&gt;
&lt;img src="image.jpg" alt="image description" width="773" height="432" /&gt;
&lt;img src="image.jpg" alt="image description" width="773" height="432" /&gt;
&lt;img src="image.jpg" alt="image description" width="773" height="432" /&gt;
&lt;div&gt;
    &lt;img src="image.jpg" alt="image description" width="773" height="432" /&gt;
    &lt;img src="image.jpg" alt="image description" width="773" height="432" /&gt;
&lt;/div&gt;
</code></pre>

<p>Cheers</p>
