Search results
This commit is contained in:
@@ -76,3 +76,11 @@ function windycoys_share_twitter_url() {
|
||||
$link = get_the_permalink();
|
||||
echo $url . urlencode($title . ': ' . $link . ' by @WindyCOYS');
|
||||
}
|
||||
|
||||
function windycoys_search_posts_per_page($query) {
|
||||
if ($query->is_search) {
|
||||
$query->set( 'posts_per_page', '10' );
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
add_filter('pre_get_posts', 'windycoys_search_posts_per_page');
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
<symbol id="icon-hash" viewBox="0 0 448 512">
|
||||
<path fill="currentColor" d="M440.667 182.109l7.143-40c1.313-7.355-4.342-14.109-11.813-14.109h-74.81l14.623-81.891C377.123 38.754 371.468 32 363.997 32h-40.632a12 12 0 0 0-11.813 9.891L296.175 128H197.54l14.623-81.891C213.477 38.754 207.822 32 200.35 32h-40.632a12 12 0 0 0-11.813 9.891L132.528 128H53.432a12 12 0 0 0-11.813 9.891l-7.143 40C33.163 185.246 38.818 192 46.289 192h74.81L98.242 320H19.146a12 12 0 0 0-11.813 9.891l-7.143 40C-1.123 377.246 4.532 384 12.003 384h74.81L72.19 465.891C70.877 473.246 76.532 480 84.003 480h40.632a12 12 0 0 0 11.813-9.891L151.826 384h98.634l-14.623 81.891C234.523 473.246 240.178 480 247.65 480h40.632a12 12 0 0 0 11.813-9.891L315.472 384h79.096a12 12 0 0 0 11.813-9.891l7.143-40c1.313-7.355-4.342-14.109-11.813-14.109h-74.81l22.857-128h79.096a12 12 0 0 0 11.813-9.891zM261.889 320h-98.634l22.857-128h98.634l-22.857 128z"></path>
|
||||
</symbol>
|
||||
<symbol id="icon-profile" viewBox="0 0 496 512">
|
||||
<path fill="currentColor" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm128 421.6c-35.9 26.5-80.1 42.4-128 42.4s-92.1-15.9-128-42.4V416c0-35.3 28.7-64 64-64 11.1 0 27.5 11.4 64 11.4 36.6 0 52.8-11.4 64-11.4 35.3 0 64 28.7 64 64v13.6zm30.6-27.5c-6.8-46.4-46.3-82.1-94.6-82.1-20.5 0-30.4 11.4-64 11.4S204.6 320 184 320c-48.3 0-87.8 35.7-94.6 82.1C53.9 363.6 32 312.4 32 256c0-119.1 96.9-216 216-216s216 96.9 216 216c0 56.4-21.9 107.6-57.4 146.1zM248 120c-48.6 0-88 39.4-88 88s39.4 88 88 88 88-39.4 88-88-39.4-88-88-88zm0 144c-30.9 0-56-25.1-56-56s25.1-56 56-56 56 25.1 56 56-25.1 56-56 56z"></path>
|
||||
</symbol>
|
||||
<symbol id="icon-reply" viewBox="0 0 576 512">
|
||||
<path fill="currentColor" d="M11.093 251.65l175.998 184C211.81 461.494 256 444.239 256 408v-87.84c154.425 1.812 219.063 16.728 181.19 151.091-8.341 29.518 25.447 52.232 49.68 34.51C520.16 481.421 576 426.17 576 331.19c0-171.087-154.548-201.035-320-203.02V40.016c0-36.27-44.216-53.466-68.91-27.65L11.093 196.35c-14.791 15.47-14.791 39.83 0 55.3zm23.127-33.18l176-184C215.149 29.31 224 32.738 224 40v120c157.114 0 320 11.18 320 171.19 0 74.4-40 122.17-76.02 148.51C519.313 297.707 395.396 288 224 288v120c0 7.26-8.847 10.69-13.78 5.53l-176-184a7.978 7.978 0 0 1 0-11.06z"></path>
|
||||
</symbol>
|
||||
|
||||
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 8.2 KiB |
@@ -22,7 +22,7 @@
|
||||
<article class="article">
|
||||
<h1 class="article__title">Sorry, there is no article to display</h1>
|
||||
<div class="article__content">
|
||||
<a class="link" href="<?php get_site_url() ?>/">Go back home</a>
|
||||
<a class="link" href="<?php echo get_site_url() ?>/">Go back home</a>
|
||||
</div>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -10,14 +10,26 @@ $links = paginate_links(array(
|
||||
));
|
||||
|
||||
function get_previous_url($base_url, $page) {
|
||||
return $base_url . ($page - 1);
|
||||
$qs = $_SERVER['QUERY_STRING'];
|
||||
$url = $base_url . ($page - 1);
|
||||
if ($qs) {
|
||||
$url .= '/?' . $qs;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
function get_next_url($base_url, $page) {
|
||||
$qs = $_SERVER['QUERY_STRING'];
|
||||
$url = $base_url;
|
||||
if ($page === 0) {
|
||||
return $base_url . '2';
|
||||
$url .= '2';
|
||||
} else {
|
||||
$url .= ($page + 1);
|
||||
}
|
||||
return $base_url . ($page + 1);
|
||||
if ($qs) {
|
||||
$url .= '/?' . $qs;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
function format_link($link) {
|
||||
if (strpos($link, 'page-numbers dots')) {
|
||||
|
||||
76
theme/search.php
Normal file
76
theme/search.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
global $wp_query;
|
||||
get_header();
|
||||
?>
|
||||
<main class="page">
|
||||
<section class="page__logo">
|
||||
<?php get_template_part('partials/logo') ?>
|
||||
</section>
|
||||
<section class="page__content">
|
||||
<div class="content">
|
||||
<h1 class="title">
|
||||
<?php
|
||||
$query = $_GET['s'];
|
||||
echo $wp_query->found_posts.' results matching "' . $query . '" found.';
|
||||
?>
|
||||
</h1>
|
||||
<ol class="search-results">
|
||||
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
|
||||
<?php $username = get_the_author_meta('nickname') ?>
|
||||
<?php $date = get_the_date('jS F, Y', $id).' at '.get_the_date('H:i', $id) ?>
|
||||
<li class="search-results__content">
|
||||
<div class="search-result">
|
||||
<div class="search-result__head">
|
||||
<div class="search-result__title">
|
||||
<a class="link" href="<?php the_permalink(); ?>">
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-result__body">
|
||||
<?php echo the_excerpt() ?>
|
||||
</div>
|
||||
<div class="search-result__foot">
|
||||
<p class="search-result__metadata">
|
||||
<span class="search-result__icon">
|
||||
<svg class="icon icon--extra-small" aria-hidden="true">
|
||||
<use href="#icon-profile"></use>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="search-result__text"><?php echo $username ?></span>
|
||||
<span class="search-result__icon">
|
||||
<svg class="icon icon--extra-small" aria-hidden="true">
|
||||
<use href="#icon-calendar"></use>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="search-result__text"><?php echo $date ?></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php endwhile; ?>
|
||||
</ol>
|
||||
</div>
|
||||
</section>
|
||||
<section class="page__pagination">
|
||||
<?php get_template_part('partials/pagination') ?>
|
||||
</section>
|
||||
<?php else: ?>
|
||||
<section class="page__article">
|
||||
<article class="article">
|
||||
<h1 class="article__title">Sorry, no results found.</h1>
|
||||
<div class="article__content">
|
||||
<a class="link" href="<?php echo get_site_url() ?>/">Go back home</a>
|
||||
</div>
|
||||
</article>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
<section class="page__banner">
|
||||
<?php get_template_part('partials/banner') ?>
|
||||
</section>
|
||||
<section class="page__footer">
|
||||
<?php get_template_part('partials/footer') ?>
|
||||
</section>
|
||||
</main>
|
||||
<?php get_template_part('partials/navigation') ?>
|
||||
<?php get_footer() ?>
|
||||
@@ -1,4 +1,4 @@
|
||||
<form id="searchform" role="search" method="get" action="<?php get_site_url()?>">
|
||||
<form id="searchform" role="search" method="get" action="<?php echo get_site_url()?>">
|
||||
<div class="search">
|
||||
<label class="search__label" for="searchinput">
|
||||
Search
|
||||
|
||||
Reference in New Issue
Block a user