add search
This commit is contained in:
77
search.php
Normal file
77
search.php
Normal 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(); ?>
|
||||
Reference in New Issue
Block a user