根据WP codex,have\\u posts()将在成功时返回True,失败时返回false。在循环中调用此函数将导致无限循环。所以你需要使用endwhile;
$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();
endwhile;
}
else:
echo "nothing found.";
endif;
?>