默认搜索功能如果搜索表单为空,则返回主页,我希望它返回“对不起,您的搜索未返回结果”页面。
而这张票告诉我,这应该是函数的方式!除了使用.htaccess重定向以外,有人知道如何更改它吗?
我正在使用以下search.php文件:
<div id="content" class="clearfix">
<div id="main" class="col700 left clearfix" role="main">
<h1 class="archive_title"><span>Search Results for:</span> <?php echo esc_attr(get_search_query()); ?></h1>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?>>
<header>
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<p class="meta"><?php _e("Posted", "bonestheme"); ?> <time datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_time('F jS, Y'); ?></time> <?php _e("by", "bonestheme"); ?> <?php the_author_posts_link(); ?> <span class="amp">&</span> <?php _e("filed under", "bonestheme"); ?> <?php the_category(', '); ?>.</p>
</header> <!-- end article header -->
<section class="post_content">
<?php the_excerpt('<span class="read-more">Read more on "'.the_title('', '', false).'" »</span>'); ?>
</section> <!-- end article section -->
<footer>
</footer> <!-- end article footer -->
</article> <!-- end article -->
<?php endwhile; ?>
<?php if (function_exists('page_navi')) { // if expirimental feature is active ?>
<?php page_navi(); // use the page navi function ?>
<?php } else { // if it is disabled, display regular wp prev & next links ?>
<nav class="wp-prev-next">
<ul class="clearfix">
<li class="prev-link"><?php next_posts_link(_e('« Older Entries', "bonestheme")) ?></li>
<li class="next-link"><?php previous_posts_link(_e('Newer Entries »', "bonestheme")) ?></li>
</ul>
</nav>
<?php } ?>
<?php else : ?>
<!-- this area shows up if there are no results -->
<article id="post-not-found">
<header>
<h1>No Results Found</h1>
</header>
<section class="post_content">
<p>Sorry, but the requested resource was not found on this site.</p>
</section>
<footer>
</footer>
</article>
<?php endif; ?>
</div> <!-- end #main -->
<div id="sidebar1" class="sidebar right col220">
<?php get_search_form(); ?>
</div>
</div> <!-- end #content -->
`