<?php $i = 1; if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
<li>
<span class="li--span"><span class="li--span--category"><?php the_category( ', ' ); ?></span></span>
<a href="<?php the_permalink() ?>" class="li--a">
<span class="little_content"><?php the_title(); ?></span>
</a>
</li>
<?php if ( $i == 4 ) { echo 'картинка'; } ?>">
<?php $i++; endwhile; ?>