我正在为一个工作聚合网站设计一个主题(目前我使用的是默认的二十四个) .

我面临的一个问题是,当我从具有适当关键字的类别页面搜索时,我得到了结果 . 从搜索结果页面我再次使用不在数据库中的术语进行搜索,它显示没有找到任何内容 .

直到这一切正常发生 . 但是,如果我再次使用不在数据库中的关键字进行搜索,则会显示找不到任何内容,并将类别更改为null . 因此,如果我使用适当的关键字再次搜索,结果将显示在其他类别中

这是该网站的链接

http://alltopjobs.net/country/india

这是search.php代码

<?php
/**
 * The template for displaying Search Results pages
 *
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0
 */

get_header(); ?>
<?php
if ($_GET['cat'] != '') {
	$posts = query_posts($query_string . '&post_type=post'); // return only posts
} else {
	$posts = query_posts($query_string . '&post_type=page'); // return only posts
}
?>
<?php $category = get_the_category(); ?>
<form  method="get" id="jobsearch" action="<?php bloginfo('home'); ?>">
	<input type="text" placeholder="Search any jobs here..." required value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" />
     <input type="hidden" name="cat" value="<?php echo $category[0]->cat_ID; ?>" />
	<button type="submit" id="jobsubmit" value="Search Jobs" />FIND JOBS</button>
</form>

	<section id="primary" class="content-area">
		<div id="content" class="site-content" role="main">

			<?php if ( have_posts() ) : ?>

			<header class="page-header">
				<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentyfourteen' ), get_search_query() ); ?></h1>
			</header><!-- .page-header -->

				<?php
					// Start the Loop.
					while ( have_posts() ) : the_post();

						/*
						 * Include the post format-specific template for the content. If you want to
						 * use this in a child theme, then include a file called called content-___.php
						 * (where ___ is the post format) and that will be used instead.
						 */
						get_template_part( 'content', get_post_format() );

					endwhile;
					// Previous/next post navigation.
					twentyfourteen_paging_nav();

				else :
					// If no content, include the "No posts found" template.
					get_template_part( 'content', 'none' );

				endif;
			?>

		</div><!-- #content -->
	</section><!-- #primary -->

不知道如何解决这个问题 . 任何解决此问题的方法都非常感谢 . 谢谢