The above named function is called from the library/template.php file, it creates a call to have_posts() and essentially pushes WordPress into "the_loop()" earlier that would normally be expected. This can have unexpected consequences in many other areas.
One suggestion would be to fine an alternative way of getting the code you need but a quicker interim fix might be to reset the WordPress query once this function finishes by adding:
wp_reset_query();
into the function, either at the end or just after the have_posts() loop.