This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Query results – Page navigation

Resolved 5 replies premiumthemetheme-vantage
10 years ago · Last reply by Andrew Misplon 10 years ago

Hello,
I’ve made a custom search for my website and I want the results to be paginated.
The code is:

$args = array(
's' => $keyword,
'orderby' => 'title',
'post_type' => 'any',
'order' => 'ASC',
'posts_per_page' => '10',
'paged' => $paged,
);
?>

Search Results for:

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

5
  1. George D. 10 years, 10 months ago

    Looks like the code wasn’t displayed. I try again:

    $args = array(
    	's' => $keyword,
    	'orderby' => 'title',
    	'post_type' => 'any',
    	'order'   => 'ASC',
    	'posts_per_page' => '10',
    	'paged' => $paged,
    );
    ?>
    			<h2 >Search Results for: <?php echo $keyword; ?></h2>
    <?php	
    $the_query = new WP_Query( $args ); ?>
    <?php if ( $the_query->have_posts() ) : ?>
    	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    		<li>
    			<a class="title-home" href="<?php the_permalink(); ?>"><span class="title-home"><?php the_title(); ?></span></a>
    		</li>
    		<?php endwhile; ?>
    		<?php vantage_content_nav( 'nav-below' ); ?>
    	<?php wp_reset_postdata(); ?>
    <?php else : ?>
    	<?php _e( 'Sorry, no articles matched your criteria.' ); ?>
    <?php endif; ?>
  2. George D. 10 years, 10 months ago

    The results appear OK but the pagination links doesn’t show up.
    What am I doing wrong?
    Thank you,
    George D.

  3. Magus Staff 10 years, 10 months ago

    Hi George

    It may be that you are not passing the paging info in the post arguments. Please see the answer to this post.

    http://wordpress.stackexchange.com/questions/120407/how-to-fix-pagination-for-custom-loops

    Magus

  4. George D. 10 years, 10 months ago

    Thank you Magus.

    I’ve figured out.

    Have a nice day,
    George D.

  5. Andrew Misplon Staff 10 years, 10 months ago

    Glad to hear you made progress on this.

    All the best :)

Replies on this thread are closed.

Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Have a different question or issue?

Start New Thread