当前我有我的搜索只返回有结果的页面的标题,是否有方法显示摘录
这就是我所拥有的
<?php get_header(); ?>
<section class="page-wrap">
<div class="container">
<div class="col-lg-9 section-space--ptb_30">
<?php
$s=get_search_query();
$args = array(
\'s\' =>$s
);
// The Query
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
_e("<h2 style=\'padding-bottom:20px;\'>Search Results for \'".get_query_var(\'s\')."\'</h2>");
while ( $the_query->have_posts() ) {
$the_query->the_post();
?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php
}
}else{
?>
<h2 style=\'font-weight:bold;color:#000\'>Nothing Found</h2>
<div class="alert alert-info">
<p>Sorry, but nothing matched your search criteria. Please try again with some different keywords.</p>
</div>
<?php } ?>
</div>
</div>
</section>
<?php get_footer(); ?>