How to add item to array? <p>The item :</p> <pre><code>$image = wp_get_attachment_image_src( get_post_thumbnail_id( $loop-&gt;post-&gt;ID ), 'single-post-thumbnail' ); </code></pre> <p>The array :</p> <pre><code>$attachment_ids = $product-&gt;get_gallery_attachment_ids(); foreach( $attachment_ids as $attachment_id ) { echo '&lt;img src="'.$image_link = wp_get_attachment_url( $attachment_id ).'"&gt;'; } </code></pre> <p>I need to add the item $img_url in the beginning of the array.</p>