-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
51 lines (51 loc) · 2.3 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
# The template for displaying search page.
?>
<?php get_header(); ?>
<main class="layout__main">
<article class="post">
<div class="post__meta">
<h1 class="post__title">Search results for: <?php printf(get_search_query()); ?></h1>
</div>
</article>
<div class="row">
<?php
while (have_posts()) : the_post();
?>
<div class="col-12 col-lg-6 post-matrix__item">
<article class="post-preview<?php echo has_post_thumbnail() ? '' : ' post-preview_text-only' ?>">
<?php if (has_post_thumbnail()) : ?>
<a href="<?php the_permalink() ?>">
<img alt="" class="post-preview__thumb" src="<?php echo wp_get_attachment_image_url(get_post_thumbnail_id(), 'full') ?>" />
</a>
<?php endif; ?>
<div class="post-preview__meta">
<h2 class="post-preview__title">
<a href="<?php the_permalink(); ?>" class="link link_text"><?php the_title(); ?></a>
</h2>
<div class="post-meta">
<span class="post-meta__date">
<?php echo get_the_date('j F Y'); ?>
</span>
<span class="post-meta__category">in
<?php
$links = array_map(function ($category) {
return sprintf(
'<a href="%s" class="link link_text">%s</a>', // Шаблон вывода ссылки
esc_url(get_category_link($category)), // Ссылка на рубрику
esc_html($category->name) // Название рубрики
);
}, get_the_category());
echo implode(' and ', $links);
?>
</span>
</div>
</div>
</article>
</div>
<?php
endwhile;
?>
</div>
</main>
<?php get_footer(); ?>