Wordpress 使用简单查询的wp_查询中的无限循环

Wordpress 使用简单查询的wp_查询中的无限循环,wordpress,Wordpress,这段代码进入无限循环!我做错了什么?只有一个帖子叫“你好”。阻止它的唯一方法是使用break在while中 谢谢你的帮助 $gotop="hello there"; $args = array( 's' => $gotop, 'post_type' => 'post' ); $wp_query = new WP_Query($args); if ( $wp_query->have_posts() ) : ?> <?

这段代码进入无限循环!我做错了什么?只有一个帖子叫“你好”。阻止它的唯一方法是使用
break在while中

谢谢你的帮助

   $gotop="hello there";

$args = array(

    's' => $gotop,
    'post_type' => 'post'

);

$wp_query = new WP_Query($args);

if ( $wp_query->have_posts() ) :  ?>

        <?php

        while ( $wp_query->have_posts() ) {
      $wp_query->the_post();
}

else:
  echo "nothing found.";
endif;
?>
$gotop=“你好”;
$args=数组(
's'=>$gotop,
“职位类型”=>“职位”
);
$wp\u query=新的wp\u查询($args);
如果($wp\u query->have\u posts()):?>

您使用的是
$wp\u query
,它是wordpress的全局查询变量,因此每次它检查新帖子时

使用其他变量或下面的代码代替$wp_查询

$gotop="hello there";

$args = array(

    's' => $gotop,
    'post_type' => 'post'

);

$custom_query = new WP_Query($args);

if ( $custom_query->have_posts() ) :  ?>

        <?php

        while ( $custom_query->have_posts() ) {
      $custom_query->the_post();
}

else:
  echo "nothing found.";
endif;
?>
$gotop=“你好”;
$args=数组(
's'=>$gotop,
“职位类型”=>“职位”
);
$custom\u query=新的WP\u查询($args);
如果($custom\u query->have\u posts()):?>

$wp\u查询是问题所在,谢谢。我重新命名了它并开始工作!