WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi
Pagination and Custom Query (1 post)

  1. admin@norris-stevens.com
    Member
    Posted 1 year ago #

    I have read numerous articles on using pagination with custom query, but I'm still unable to get my page to work properly. I know that the pagination works, but my code is wrong somewhere because when I click page 2, page 1 appears instead. Please help. My code is below. Thanks so much.

    <?php
    if(isset($_REQUEST['sort'])){
    	if($_REQUEST['sort'] == 'desc' )
    		$order = "&orderby=title&order=DESC";
    	else if($_REQUEST['sort'] == 'asc' )
    		$order = "&orderby=title&order=ASC";
    }
    
    else 
    
    $order = "&orderby=ID&order=DESC"; 
    
    ?>
    
    <form method="post" id="order">
      <select name="sort" onchange='this.form.submit()'>
        <option value="">Sort by</option>
        <option value="desc">Sort by Desc</option>
        <option value="asc">Sort by Asc</option>
      </select>
    </form>
    
    <?php $my_query = new WP_Query( array( 'cat' => 30, 'paged' => get_query_var('paged') ) . $order 
    
    ); while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
    
    CONTENT IS HERE
    
    <?php endwhile; ?>
    
    <?php wp_pagenavi( array( 'query' => $my_query ) ); ?>
    
    <?php wp_reset_postdata(); ?>

    http://wordpress.org/extend/plugins/wp-pagenavi/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by admin@norris-stevens.com
  • This topic is not resolved
  • WordPress version: 3.4.2