I have a WP_Query loop running in a function that's attached to the 'admin_enqueue_scripts' hook
add_action( 'admin_enqueue_scripts', 'rs_get_scripts');
function rs_get_scripts() {
//enqueue js file
...
$args = array( 'post_type' => 'events', 'posts_per_page' => -1);
$query = new WP_Query($args);
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
/* bug occurs no matter what code is in here */
//get data about each post
...
endwhile;endif;wp_reset_query();
//localize the data I got from each events post type into js file
...
}
What is happening is that running this loop at the time of 'admin_enqueue_scripts' hook seems to screw up the admin. The bug is that when I try to create a new post, page or any other Custom Post Type, Wordpress always redicrects me to to create a post of the post type I am querying in the loop above. In this case it's "events". I tried changing the loop to query_posts and get_posts but with no luck. Any ideas?