I need to display search result in the same page. This is a page template where display some custom post type (Blog). I have added a search feild to this page and I need to display it search result in same page when some one search. Can anyone please help me with this.
<form id="searchform" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<input type="text" class="search-field" name="s" placeholder="Search" value="<?php echo get_search_query(); ?>">
<input type="submit" value="Search">
</form>
<?php
$args = array(
'post_type' => 'blog_post',
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => 6
);
$service_slides = new WP_Query( $args );
if( $service_slides->have_posts()) { ?>
<div class="col-lg-12">
<div class="row">
<?php while ( $service_slides->have_posts() ) : $service_slides->the_post(); ?>
<div class="blog-post-col col-lg-4 col-md-6 col-sm-6 col-xs-12">
<div class="blog-img-wrapper">
<?php MultiPostThumbnails::the_post_thumbnail( 'blog_post','recent-image' ); ?>
<a class="blog-post-title"><?php the_title(); ?></a>
</div>
<span class="b-post-date"><?php echo get_the_date('M j Y'); ?></span>
<p><?php echo wp_trim_words( get_the_content(), 40, '</p><a class="link-btn" href="'.get_permalink() . '"> Rear More </a>'); ?>
</div>
<?php endwhile; ?>
</div>
</div>
<?php } ?>
Aucun commentaire:
Enregistrer un commentaire