108 lines
2.3 KiB
PHP
108 lines
2.3 KiB
PHP
<?php
|
||
/**
|
||
* The main template file.
|
||
*
|
||
*/
|
||
|
||
get_header();?>
|
||
|
||
|
||
<?if (trim($s) !== ''):?>
|
||
|
||
<?$params = [
|
||
'post_type' => 'post',
|
||
's' => $s,
|
||
'post_status' => 'publish',
|
||
'posts_per_page' => 20
|
||
]?>
|
||
|
||
|
||
|
||
<div id="content">
|
||
|
||
<h1 id="mainpage-title">Поиск:</h1>
|
||
|
||
|
||
|
||
<div id="search-form">
|
||
<form action="<?php bloginfo( 'url' ); ?>" method="get">
|
||
<input class="search-text" type="text" name="s" placeholder="Найти" value="<?=$s?>"/>
|
||
<input class="search_submit" type="submit" value="Найти"/>
|
||
|
||
<div class="search-result">
|
||
По запросу «<?php
|
||
$allsearch = new WP_Query($params);
|
||
$key = esc_html($s, 1);
|
||
$count = $allsearch->post_count; _e('');
|
||
_e('<span class="search-terms">');
|
||
echo $key; _e('</span>» найдено ');
|
||
if ($count == 1):
|
||
echo $count . ' '; _e('результат');
|
||
else:
|
||
if ($count > 4):
|
||
echo $count . ' '; _e('результатов');
|
||
else:
|
||
echo $count . ' '; _e('результата');
|
||
endif;
|
||
endif;
|
||
//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()) :?>
|
||
<div class="search-card-box">
|
||
|
||
<?php while(have_posts()) : the_post();?>
|
||
|
||
|
||
|
||
<div class="search-card">
|
||
|
||
<div class="search-card-title"><a href="<?the_permalink();?>"><?the_title();?></a></div>
|
||
<?if ( has_post_thumbnail() ) :?>
|
||
<img class="search-card-img" src="<?php echo get_the_post_thumbnail_url(null, 'full'); ?>" width="239" alt="<?the_title();?>">
|
||
<?endif?>
|
||
<div><?the_excerpt();?></div>
|
||
<div class="mini-card-body">
|
||
<div class="news_date"><?the_time('j F Y, G:i');?></div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
|
||
|
||
<?php endwhile;?>
|
||
</div>
|
||
|
||
<?get_template_part( '/blocks/paginator');?>
|
||
|
||
|
||
<?php endif;?>
|
||
|
||
<?php endif;?>
|
||
|
||
<?wp_reset_postdata();?>
|
||
|
||
|
||
</div>
|
||
|
||
|
||
<?php get_footer(); ?>
|