我在附加到“admin\\u enqueue\\u scripts”挂钩的函数中运行了一个WP\\u查询循环
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
...
}
发生的情况是,在“admin\\u enqueue\\u scripts”挂钩时运行此循环似乎会搞糟管理员。问题是,当我尝试创建新的帖子、页面或任何其他自定义帖子类型时,Wordpress总是会重新更正我,以创建我在上面的循环中查询的帖子类型。在这种情况下,它是“事件”。我尝试更改循环以查询\\u帖子和获取\\u帖子,但没有成功。有什么想法吗?