-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
executable file
·74 lines (68 loc) · 1.72 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
$sections = [
[
'component' => 'forms/form',
'data' => [
'theme' => 'search',
'attributes' => [
'method' => 'get',
'action' => esc_url(home_url('/'))
],
'fields' => [
[
'component' => 'forms/text-input',
'data' => [
'label' => 'Search label',
'input' => [
'attributes' => [
'name' => 's'
]
]
]
],
[
'component' => 'forms/button',
'data' => [
'content' => 'Search',
'type' => 'submit',
]
]
]
]
]
];
if (have_posts()) {
$items = [];
while (have_posts()) {
the_post();
$items[] = [
'component' => 'cards/search-card',
'data' => [
'post_type' => get_post_type(),
'title' => get_title(),
'excerpt' => get_excerpt(),
'link' => [
'content' => 'Read more',
'url' => get_permalink()
]
]
];
}
$sections[] = [
'component' => 'common/layout',
'data' => [
'theme' => 'cards',
'items' => $items
]
];
} else {
$sections = [
'component' => 'common/content',
'data' => [
'content' => 'No results message'
]
];
}
page([
'sections' => $sections
]);