Refactor search toggle to Bootstrap and add search results template
This commit is contained in:
85
search.php
85
search.php
@@ -8,47 +8,66 @@ get_header();
|
||||
|
||||
<div class="bg-light py-5 border-bottom mb-5">
|
||||
<div class="container text-center">
|
||||
<h1 class="display-5 fw-bold mb-3">
|
||||
<?php
|
||||
/* translators: %s: search query. */
|
||||
printf(esc_html__('Search Results for: %s', 'wisdom1'), '<span>' . get_search_query() . '</span>');
|
||||
?>
|
||||
</h1>
|
||||
<?php if (have_posts()): ?>
|
||||
<h1 class="display-4 fw-bold mb-3 font-serif">
|
||||
<?php printf(esc_html__('Search Results for: %s', 'wisdom1'), '<span class="text-primary">' . get_search_query() . '</span>'); ?>
|
||||
</h1>
|
||||
<p class="lead text-muted mx-auto w-75 font-sans">
|
||||
<?php printf(esc_html__('Showing results matching your query.'), 'wisdom1'); ?>
|
||||
</p>
|
||||
<?php else: ?>
|
||||
<h1 class="display-4 fw-bold mb-3 font-serif"><?php esc_html_e('Nothing Found', 'wisdom1'); ?></h1>
|
||||
<p class="lead text-muted mx-auto w-75 font-sans">
|
||||
<?php esc_html_e('Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'wisdom1'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<main id="primary" class="site-main container mb-5">
|
||||
<div class="row g-4">
|
||||
<?php if (have_posts()): ?>
|
||||
<div class="container mb-5">
|
||||
<main id="primary" class="site-main">
|
||||
<div class="row g-4">
|
||||
<?php
|
||||
/* Start the Loop */
|
||||
while (have_posts()):
|
||||
the_post();
|
||||
get_template_part('template-parts/content', 'card');
|
||||
endwhile;
|
||||
if (have_posts()):
|
||||
while (have_posts()):
|
||||
the_post();
|
||||
get_template_part('template-parts/content', 'card');
|
||||
endwhile;
|
||||
|
||||
the_posts_navigation(array(
|
||||
'screen_reader_text' => 'Posts navigation',
|
||||
'prev_text' => '<span class="btn btn-outline-primary">← Older Results</span>',
|
||||
'next_text' => '<span class="btn btn-outline-primary">Newer Results →</span>',
|
||||
'class' => 'd-flex justify-content-between my-5 col-12'
|
||||
));
|
||||
|
||||
else:
|
||||
?>
|
||||
<div class="col-12 text-center py-5">
|
||||
<h2 class="h3 mb-4">Nothing Found</h2>
|
||||
<p class="lead text-muted mb-4">Sorry, but nothing matched your search terms. Please try again with some
|
||||
different keywords.</p>
|
||||
<div class="search-container mx-auto" style="max-width: 500px;">
|
||||
<?php get_search_form(); ?>
|
||||
echo '</div>'; // close row
|
||||
|
||||
the_posts_navigation(array(
|
||||
'screen_reader_text' => 'Posts navigation',
|
||||
'prev_text' => '<span class="btn btn-outline-primary">← Older Results</span>',
|
||||
'next_text' => '<span class="btn btn-outline-primary">Newer Results →</span>',
|
||||
'class' => 'd-flex justify-content-between my-5'
|
||||
));
|
||||
else:
|
||||
?>
|
||||
<div class="col-12 col-md-8 mx-auto text-center py-5">
|
||||
<div class="card border-0 bg-light p-5 rounded-4 text-center">
|
||||
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||
stroke-linecap="round" stroke-linejoin="round" class="text-muted mx-auto mb-4">
|
||||
<circle cx="11" cy="11" r="8"></circle>
|
||||
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
||||
</svg>
|
||||
<h3 class="h4 font-serif fw-bold mb-3">No matching articles found.</h3>
|
||||
<p class="text-muted mb-4">Try searching for different keywords or explore our latest articles
|
||||
below.</p>
|
||||
<form role="search" method="get" class="d-flex w-75 mx-auto"
|
||||
action="<?php echo esc_url(home_url('/')); ?>">
|
||||
<input type="search" class="form-control form-control-lg me-2" placeholder="Search wisdom..."
|
||||
value="<?php echo get_search_query(); ?>" name="s">
|
||||
<button type="submit" class="btn btn-primary btn-lg px-4">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</div><!-- .row -->
|
||||
</main><!-- #main -->
|
||||
endif;
|
||||
?>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
get_footer();
|
||||
|
||||
Reference in New Issue
Block a user