This repository was archived by the owner on Jan 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearchform.php
More file actions
91 lines (80 loc) · 2.19 KB
/
searchform.php
File metadata and controls
91 lines (80 loc) · 2.19 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
$action = esc_url(home_url('/'));
$placeholder = esc_attr_x('Search …', 'placeholder');
$query = get_search_query();
$autofocus = is_404() || is_search();
?>
<style>
.search-form {
display: flex;
flex-wrap: nowrap;
}
.search-form > label {
width: 100%;
}
.search-form input {
padding: 1rem;
font-size: 1.2rem;
}
.search-form button {
background: black;
border: #3a3b3c 1px solid;
border-left: 0;
padding: 0 20px;
}
</style>
<form role="search" method="get" class="search-form" action="<?= $action ?>">
<label>
<input
<?= $autofocus ? 'autofocus' : '' ?>
type="search"
class="search-field"
placeholder="<?= $placeholder ?>"
value="<?= $query ?>"
name="s"
autocomplete="off"
/>
</label>
<button type="submit" class="search-submit" aria-label="search">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-search"
viewBox="0 0 16 16">
<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/>
</svg>
</button>
</form>
<style>
.terms {
display: flex;
gap: .5rem;
list-style: none;
padding: 0;
flex-wrap: wrap;
justify-content: space-between;
}
.terms a {
display: inline-block;
padding: 0.35em 0.65em;
font-size: .75em;
font-weight: 700;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: 0.25rem;
background-color: rgb(47 51 55 / 80%);
}
</style>
<?php
$tags = get_tags();
$cats = get_categories();
$terms = array_merge($cats, $tags);
?>
<ul class="terms">
<?php foreach ($terms as $term): ?>
<li>
<a href="<?= get_term_link($term->term_id) ?>">
<?= $term->name ?>
</a>
</li>
<?php endforeach; ?>
</ul>