125 lines
5.8 KiB
PHP
125 lines
5.8 KiB
PHP
<?php
|
|
get_header();
|
|
$results_count = $wp_query->found_posts;
|
|
$stylesheet = get_field('style_sheet');
|
|
$company_logo = get_field('company_logo', 'option');
|
|
?>
|
|
|
|
<section class="container search-results-page-container consumer-brand">
|
|
<div class="row p-2">
|
|
<div class="col">
|
|
<h1 class="text-center">Search</h1>
|
|
</div>
|
|
</div>
|
|
<div class="row py-5 search-form-wrapper">
|
|
<div class="col">
|
|
<form id="searchform" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>">
|
|
<div class="form-group">
|
|
<input type="text" id="searchInput" class="search-field form-control mb-2" aria-describedby="search" name="s" placeholder="Search" value="<?php echo get_search_query(); ?>">
|
|
</div>
|
|
<button id="searchBtn" type="submit" value="Search" class="btn btn-primary">Search</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row d-flex justify-content-center search-results-wrapper">
|
|
<div class="col">
|
|
<?php if (have_posts()) : ?>
|
|
<h4 class="mb-2"><?php _e('Search Results'); ?></h4>
|
|
<?php while (have_posts()) : the_post(); ?>
|
|
<article class="row py-4" <?php post_class(); ?>>
|
|
<!-- <div class="col-4">
|
|
<div class="post-img">
|
|
<?php
|
|
$image_id = get_the_post_thumbnail( $post->ID, 'medium' );
|
|
$alt_text = get_post_meta( $image_id , '_wp_attachment_image_alt', true );
|
|
?>
|
|
<?php if( !empty(get_the_post_thumbnail()) ) : ?>
|
|
<img class="img-fluid" src="<?php echo the_post_thumbnail_url( $image_id, 'medium' ); ?>" alt="<?php echo $alt_text; ?>" />
|
|
<?php else : ?>
|
|
<div class="d-flex justify-content-center align-items-center img-placeholder">
|
|
<img class="img-fluid" src="<?php echo $company_logo['url']; ?>" alt="<?php echo $company_logo['alt'] ?>" />
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div> -->
|
|
<div class="col align-items-center">
|
|
<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
|
|
<div class="entry">
|
|
<p><?php echo wp_trim_words( get_the_excerpt(), 30, '...' ); ?></p>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
<hr />
|
|
<?php endwhile; ?>
|
|
|
|
<div class="row py-4 justify-content-center post-pagination">
|
|
<div class="col-6">
|
|
<h4 class="button--primary text-center"><?php next_posts_link( '< Previous', $the_query->max_num_pages ); ?></h4>
|
|
</div>
|
|
<div class="col-6">
|
|
<h4 class="button--primary text-center"><?php previous_posts_link( 'Next >' ); ?></h4>
|
|
</div>
|
|
</div>
|
|
|
|
<?php else : ?>
|
|
<p><?php _e('Sorry. We couldn’t find anything for that search. View one of our site’s pages or a recent article below.'); ?></p>
|
|
<div class="row">
|
|
<div class="col-md-6 posts">
|
|
<h3><?php _e('Recent Articles'); ?></h3>
|
|
<ul>
|
|
<?php
|
|
$args = array(
|
|
'numberposts' => '10',
|
|
'post_status' => 'publish'
|
|
);
|
|
$recent_posts = wp_get_recent_posts( $args );
|
|
foreach( $recent_posts as $recent ) {
|
|
echo '<li><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"] . '</a></li>';
|
|
}
|
|
?>
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-6 pages">
|
|
<h3><?php _e('Page Sitemap'); ?></h3>
|
|
<ul>
|
|
<?php wp_list_pages('title_li=&sort_column=menu_order'); ?>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- Category section BEGIN -->
|
|
<section class="container pb-4 post-categories-container">
|
|
<?php
|
|
$category_name = $category->name;
|
|
$categories = get_categories( array(
|
|
'taxonomy' => 'category',
|
|
'orderby' => 'name',
|
|
'parent' => 0,
|
|
'hide_empty' => 0,
|
|
) );
|
|
?>
|
|
<div class="row">
|
|
<div class="col">
|
|
<h3 class="category-title">Explore more topics:</h3>
|
|
</div>
|
|
</div>
|
|
<div class="row post-category-list">
|
|
<?php foreach($categories as $category) {
|
|
$category_name = $category->name;
|
|
if( strtolower( $category_name ) != 'uncategorized' ) { ?>
|
|
<div class="col-12 col-md-4">
|
|
<h4 class="category-item"><a href="<?php echo esc_url( get_category_link( $category->term_id ) ); ?>"><?php echo $category->name; ?></a></h4>
|
|
</div>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
</div>
|
|
</section>
|
|
<!-- Category section END -->
|
|
|
|
<?php
|
|
get_footer();
|