• Hi I’m new to WordPress so any help would be great.

    I’m trying to create a drop down menu that when selected allows the user to control the amount of posts displayed on a page, this works fine, except on the page the user can perform searches and when ever you select to display certain number of posts, it defaults back to the original query. Is it possible to stop this defaulting back and show the current search results?

    Any help would be grateful.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I would suggest working with Custom Queries and query strings (siteurl.com/?s=test&showpost=15)

    Thread Starter Jamessy

    (@jamessy)

    Thanks for your reply. I am already using query strings but my main problem is that its defaulting to the orignal query. If you go here first select “date” from the filterby drop down and then select “show per page” and choose an value, it defaults to the original query I need to store the results some how.

    Here is my code:

    <?php if($_GET['amount']) {
    			  			$show_per_page = $_GET['amount'];
    
    			 	 }else{
    					$show_per_page =10;
    				}
    				?>
    				  <?php  $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    						 query_posts("post_type=authors&posts_per_page=$show_per_page&paged=$paged"); ?>
    
                <?php  if(function_exists('wp_pagenavi')) { wp_pagenavi(); }?>
    
             <?php echo my_search_form(); ?>
    
             <?php if (class_exists('WP_Smart_Sort'))
    					{ $wpss = new WP_Smart_Sort();
    						if (method_exists($wpss,'placesort')) {
    							$wpss->placesort();
    						}
    				} ?>
              <form action="" method="get">
                  <select id="select-amount" name="" onChange="document.location.href=this.options[this.selectedIndex].value;">
                  <option value="">Show per page</option>
                  <option value="?amount=5">5</option>
                  <option value="?amount=10">10</option>
                   <option value="?amount=30">30</option>
                   <option value="?amount=40">40</option>
                  </select>
                 </form>

    Thread Starter Jamessy

    (@jamessy)

    Still struggling

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Displaying number of posts’ is closed to new replies.