patiboh
5/18/2016 - 5:16 PM

WordPress - Using wp-pagenavi in search results

WordPress - Using wp-pagenavi in search results

<?php get_template_part('templates/page', 'header'); ?>

<?php if (!have_posts()) : ?>
  <div>
  	<h2 class="entry-title"><?php _e('No results were found.', 'text_domain') ?></h2>
    <p><?php _e('Sorry, there are no documents that match your query. Choose different keywords and try again.', 'text_domain'); ?></p>
  </div>
<?php endif; 
	global $wp_query;
?>

<?php while (have_posts()) : the_post(); ?>
  <?php get_template_part('templates/content', 'search'); ?>
<?php endwhile; ?>

<?php if( function_exists( 'wp_pagenavi' ) ) { ?>

	<aside class="pagination">
		<nav class="text-center">
		    <?php wp_pagenavi( array( 'query' => $wp_query ) ); ?>
		</nav>
	</aside>

<?php } ?>