add search

This commit is contained in:
2021-09-28 22:25:21 +03:00
parent 0e42ee8071
commit 57858d1fbd
14 changed files with 639 additions and 91 deletions

77
search.php Normal file
View File

@@ -0,0 +1,77 @@
<?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>
<!--«москва» -->
<p class="search-result">По запросу «<?php
$allsearch = new WP_Query("s=$s&showposts=-1");
$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="mini-card-block">
<?php while(have_posts()) : the_post();?>
<div class="mini-card">
<?if ( has_post_thumbnail() ) :?>
<a href="<?the_permalink();?>"><img class="mini-card-img" src="<?php echo get_the_post_thumbnail_url(null, 'full'); ?>" alt="<?the_title();?>"></a>
<?endif?>
<h2 class="mini-card-title"><a href="<?the_permalink();?>"><?the_title();?></a></h2>
<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;?>
</div>
<?php get_footer(); ?>