-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
45 lines (37 loc) · 1.8 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/*
* 欢迎来到代码世界,如果你想修改多梦主题的代码,那我猜你是有更好的主意了~
* 那么请到多梦网络( https://www.dmeng.net/ )说说你的想法,数以万计的童鞋们会因此受益哦~
* 同时,你的名字将出现在多梦主题贡献者名单中,并有一定的积分奖励~
* 注释和代码同样重要~
* @author 多梦 @email [email protected]
*/
$key = get_search_query();
//~ 搜索关键词为空时跳转到 0 的搜索结果
if($key==''){
wp_redirect( add_query_arg( 's', 0 ), 301 ); exit;
}
global $wp_query;
get_header(); ?>
<?php get_header('masthead'); ?>
<div id="main" class="container page1">
<div class="row" style="margin-top:1.5em">
<div id="content" class="col-lg-12 col-md-12 archive search-archive" role="main" itemscope itemprop="mainContentOfPage" itemtype="https://schema.org/SearchResultsPage">
<?php echo dmeng_adsense('archive','top');?>
<div class="<?php echo apply_filters('dmeng_archive_panel_class', 'panel panel-default panel-archive');?>">
<div class="panel-body">
<h1 class="h3 page-header panel-archive-title"><span itemprop="name"><?php echo '搜索:'.$key; ?></span> <small> <span class="glyphicon glyphicon-list-alt"></span> <?php printf( '%s个相关结果', '<span itemprop="interactionCount">'.$wp_query->found_posts.'</span>' );?> <span class="glyphicon glyphicon-signal"></span> <?php printf( __( '%s次搜索', 'dmeng' ) , get_dmeng_traffic('search',$key) ); ?></small>
</h1>
<?php
while ( have_posts() ) : the_post();
get_template_part('content','archive');
endwhile; // end of the loop.
dmeng_paginate();
?>
</div>
</div>
<?php echo dmeng_adsense('archive','bottom');?>
</div><!-- #content -->
</div>
</div><!-- #main -->
<?php get_footer(); ?>