Below you can find a template for displaying Search Results pages. Add the code to your search.php file. If you have installed the WP-PageNavi plugin then you’ll see the pagination if the search result has more than 10 items.
<?php
/**
* The template for displaying Search Results pages.
*/
get_header();
?>
<h2><?php printf( __( 'Search Results for: %s', 'themedomain' ), '<strong>"' . get_search_query() . '"</strong>' ); ?></h2>
<div class="posts">
<?php
global $paged;
$s = $_GET['s'];
$post_types = array('post', 'page');
$args=array(
'post_type' => $post_types,
'post_status' => 'publish',
's' => $s,
'orderby' => 'date',
'order' => 'desc',
'posts_per_page' => 10,
'paged' => $paged
);
$wp_query = new WP_Query($args);
if ($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post();
?>
<!-- post-box -->
<article class="post-box">
<div class="meta">
<h3><a href="https://wordpress.stackexchange.com/questions/264107/<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p><?php _e('Posted by','themedomain');?> <?php if (!get_the_author_meta('first_name') && !get_the_author_meta('last_name')) { the_author_posts_link(); } else { echo '<a href="'.get_author_posts_url(get_the_author_meta('ID')).'">'.get_the_author_meta('first_name').' '.get_the_author_meta('last_name').'</a>'; } ?> <?php _e('· on','themedomain');?> <?php echo get_the_time('F d, Y'); ?> <?php _e('· in','themedomain');?> <?php the_category(', ') ?> <?php _e('· with','themedomain');?> <?php comments_popup_link(__('0 Comments', 'themedomain'),__('1 Comment', 'themedomain'), __('% Comments', 'themedomain')); ?></p>
</div>
<?php the_excerpt(); ?>
<p><a href="https://wordpress.stackexchange.com/questions/264107/<?php the_permalink(); ?>"><?php _e('Continue Reading →','themedomain'); ?></a></p>
</article>
<?php
endwhile;
endif;
?>
</div>
<!-- paging -->
<div class="paging">
<ul>
<?php
if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
?>
</ul>
</div>
<?php get_footer(); ?>