88 lines
1.8 KiB
PHP
88 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* The main template file.
|
|
*
|
|
*/
|
|
|
|
get_header();?>
|
|
|
|
|
|
|
|
<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="<?=$s?>" value=""/>
|
|
<input class="search_submit" type="submit" value="Найти"/>
|
|
</form>
|
|
</div>
|
|
|
|
<?if (trim($s) !== ''):?>
|
|
|
|
<?$params = [
|
|
'post_type' => 'post',
|
|
's' => $s,
|
|
'post_status' => 'publish',
|
|
'posts_per_page' => 20
|
|
]?>
|
|
|
|
<p 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(); ?></p>
|
|
|
|
<?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(); ?>
|