Cant insert wrapper div into index.php

If I understand you correctly, you want to modify your code so it looks like this at the top:

<div class="new_wrapper">
<?php

$args = array(

and this at the bottom:

<?php endwhile;
} ?>
</div>
<?php
$v = array();

It sounds like you may have been adding the <div></div> inside the <?php ?> code, which would have caused an error (and if error displaying is turned off, it would have likely resulted in a blank page).

Basically, what you’re doing here is inserting a wrapper around the main WordPress loop – including the if (have_posts()) and while (have_posts()) blocks. Keeping the wrapper outside of these two blocks means that 1) the wrapper will still be printed out when there are no posts (because it’s outside of the if block), and 2) the wrapper will only be printed once, i.e. not repeated for every post as it would if it was inside the while loop.

Hoping that solves the problem and helps you understand the logic behind it – if not apologies if I misunderstood the question!