add filters search
This commit is contained in:
@@ -40,7 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul id="header_icons">
|
<ul id="header_icons">
|
||||||
<a href="<?=get_site_url()?>?s="><li class="btn_search"></li></a>
|
<a href="<?=get_site_url()?>?s=ВиЖ"><li class="btn_search"></li></a>
|
||||||
<a href="<?=get_site_url()?>/rss/news.xml"><li class="btn_rss"></li></a>
|
<a href="<?=get_site_url()?>/rss/news.xml"><li class="btn_rss"></li></a>
|
||||||
<li class="toggle-nav" id="toggle-nav"></li>
|
<li class="toggle-nav" id="toggle-nav"></li>
|
||||||
<a href="<?=get_site_url().vij_lang('btn_lan_link', LANG_VERSION)?>"><li class="btn_lan"><nobr><?=vij_lang('btn_lan', LANG_VERSION)?></nobr></li></a>
|
<a href="<?=get_site_url().vij_lang('btn_lan_link', LANG_VERSION)?>"><li class="btn_lan"><nobr><?=vij_lang('btn_lan', LANG_VERSION)?></nobr></li></a>
|
||||||
|
|||||||
@@ -173,8 +173,10 @@ add_filter( 'single_template', function ( $single_template ) {
|
|||||||
#search
|
#search
|
||||||
function my_search_order( $query ) {
|
function my_search_order( $query ) {
|
||||||
if ($query->is_search) {
|
if ($query->is_search) {
|
||||||
|
if (!isset($_GET['search_type']) OR $_GET['search_type'] == 'date'){
|
||||||
$query->set( 'order', 'DESC' );
|
$query->set( 'order', 'DESC' );
|
||||||
$query->set( 'orderby', 'date' );
|
$query->set( 'orderby', 'date' );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
return $query;
|
return $query;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<?if (defined('TESTMODE') and TESTMODE == 1):?>
|
<?if (defined('TESTMODE') and TESTMODE == 1):?>
|
||||||
<link rel="stylesheet" href="<?php echo get_template_directory_uri();?>/style-test.css?ver=3">
|
<link rel="stylesheet" href="<?php echo get_template_directory_uri();?>/style-test.css?ver=3">
|
||||||
<?else:?>
|
<?else:?>
|
||||||
<link rel="stylesheet" href="<?php echo get_stylesheet_uri();?>?ver=283">
|
<link rel="stylesheet" href="<?php echo get_stylesheet_uri();?>?ver=315">
|
||||||
<?endif?>
|
<?endif?>
|
||||||
<link href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" rel="stylesheet">
|
<link href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" rel="stylesheet">
|
||||||
<!--<link href="<?php echo get_stylesheet_directory_uri()?>/pub/fontawesome.css" rel="stylesheet">-->
|
<!--<link href="<?php echo get_stylesheet_directory_uri()?>/pub/fontawesome.css" rel="stylesheet">-->
|
||||||
|
|||||||
48
search.php
48
search.php
@@ -7,6 +7,16 @@
|
|||||||
get_header();?>
|
get_header();?>
|
||||||
|
|
||||||
|
|
||||||
|
<?if (trim($s) !== ''):?>
|
||||||
|
|
||||||
|
<?$params = [
|
||||||
|
'post_type' => 'post',
|
||||||
|
's' => $s,
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'posts_per_page' => 20
|
||||||
|
]?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
|
||||||
@@ -16,21 +26,11 @@ get_header();?>
|
|||||||
|
|
||||||
<div id="search-form">
|
<div id="search-form">
|
||||||
<form action="<?php bloginfo( 'url' ); ?>" method="get">
|
<form action="<?php bloginfo( 'url' ); ?>" method="get">
|
||||||
<input class="search-text" type="text" name="s" placeholder="<?=$s?>" value=""/>
|
<input class="search-text" type="text" name="s" placeholder="Найти" value="<?=$s?>"/>
|
||||||
<input class="search_submit" type="submit" value="Найти"/>
|
<input class="search_submit" type="submit" value="Найти"/>
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?if (trim($s) !== ''):?>
|
<div class="search-result">
|
||||||
|
По запросу «<?php
|
||||||
<?$params = [
|
|
||||||
'post_type' => 'post',
|
|
||||||
's' => $s,
|
|
||||||
'post_status' => 'publish',
|
|
||||||
'posts_per_page' => 20
|
|
||||||
]?>
|
|
||||||
|
|
||||||
<p class="search-result">По запросу «<?php
|
|
||||||
$allsearch = new WP_Query($params);
|
$allsearch = new WP_Query($params);
|
||||||
$key = esc_html($s, 1);
|
$key = esc_html($s, 1);
|
||||||
$count = $allsearch->post_count; _e('');
|
$count = $allsearch->post_count; _e('');
|
||||||
@@ -45,7 +45,27 @@ else:
|
|||||||
echo $count . ' '; _e('результата');
|
echo $count . ' '; _e('результата');
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
//wp_reset_query(); ?></p>
|
//wp_reset_query(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="find_panel">
|
||||||
|
<select class="search-select" id="search_type" name="search_type">
|
||||||
|
<option value="date">По дате</option>
|
||||||
|
<option value="revel" <?if($_GET['search_type'] == 'revel'):?> selected<?endif?>>По релевантности</option>
|
||||||
|
</select>
|
||||||
|
<select class="search-select" id="search_date" name="search_date">
|
||||||
|
<option value="all" selected>За все время</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php if(have_posts()) :?>
|
<?php if(have_posts()) :?>
|
||||||
<div class="search-card-box">
|
<div class="search-card-box">
|
||||||
|
|||||||
22
style.css
22
style.css
@@ -270,6 +270,25 @@ a{
|
|||||||
height: 50px;
|
height: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#find_panel{
|
||||||
|
margin-top: 28px;
|
||||||
|
margin-bottom: 32px;
|
||||||
|
padding-top: 22px;
|
||||||
|
padding-bottom: 22px;
|
||||||
|
border-top: 1px solid #E9EAEB;
|
||||||
|
border-bottom: 1px solid #E9EAEB;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-select{
|
||||||
|
width: 155px;
|
||||||
|
border: 0px;
|
||||||
|
background:none;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 12px;
|
||||||
|
padding-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.search-text{
|
.search-text{
|
||||||
width: 60%;
|
width: 60%;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
@@ -284,7 +303,8 @@ a{
|
|||||||
.search-result{
|
.search-result{
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 160%;
|
line-height: 160%;
|
||||||
padding-bottom: 12px;
|
padding-top: 24px;
|
||||||
|
padding-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-card-box{
|
.search-card-box{
|
||||||
|
|||||||
Reference in New Issue
Block a user