Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how-to-add-pagination-in-search-results wordpress

function search_filter($query) {
  if ( !is_admin() && $query->is_main_query() ) {
    if ($query->is_search) {
      $query->set('paged', ( get_query_var('paged') ) ? get_query_var('paged') : 1 );
      $query->set('posts_per_page',1);
    }
  }
}
add_action( 'pre_get_posts', 'search_filter' );
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #wordpress
ADD COMMENT
Topic
Name
4+5 =