WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way of changing the post order, posts number, etc via user click?

The same way you can choose displaying questions by time and vote here at StackExchange.

How to accomplish that?

share|improve this question
Are you talking about posts ordering? If yes, it's possible. – zeo Mar 24 '11 at 11:57
Read up on JQuery and sortable lists - that will give you an idea on how to go about this - but this isn't really a WordPress question – anu Mar 24 '11 at 12:27
up vote 0 down vote accepted

Check the WP Sort Plugin, it does exactly what you need:


share|improve this answer
From a quick look at this plugin it seems to allow the administrator to set a fixed sort order for each individual category. I don't see a way for visitors to change the sort order? – Jan Fabry Apr 5 '11 at 15:56

By using the $_GET function at the top

<?php $sort= $_GET['sort']; if($sort == "title") { $order= "orderby=title"; } if($sort == "date") { $order= "orderby=date"; } ?>

You can use links like that:

<a  href="?sort=title" <?php if ($sort == "title"){ echo 'style="color:gray"'; } ?>>title</a><a href="?sort=date" <?php if ($sort == "date"){ echo 'style="color:gray"'; } ?>>Date</a>

Or a dropdown list:

<form action="" method="get">
<select name="sort" id="sorting">
  <option value="title" <?php if ($sort == "title"){ echo 'selected="selected"'; } ?> >Sort by title</option>
  <option value="date" <?php if ($sort == "date"){ echo 'selected="selected"'; }?> >Sort by publication date</option>
<input type="submit" value="Submit" /></form>

Then Comes the loop

<?php $loop = new WP_Query('cat=5&showposts=-1&'.$order.'&order=DEC'); ?><?php while ( $loop->have_posts() ) : $loop->the_post(); ?>.........<?php endwhile; ?>
share|improve this answer

Just my example based on Boldhand a way to change the title of a Custom Post Type ASC and DESC:

                $sort= esc_attr($_GET['sort']); 
                if($sort == "title") { $order= "orderby=title&order=DESC"; } 
                if($sort == "titleb") { $order= "orderby=title&order=ASC"; } 

                <div class="elementsToFilter">
                    <li><a  href="?sort=title" <?php if ($sort == "title"){ echo 'style="color:gray"'; } ?>>Title : A - Z</a></li>
                    <li><a href="?sort=titleb" <?php if ($sort == "titleb"){ echo 'style="color:gray"'; } ?>>Title : Z - A</a></li>

            <div id="containerBoxes">

                <?php $loop = new WP_Query('post_type=portfolio&posts_per_page=12'.$order); ?><?php while ( $loop->have_posts() ) : $loop->the_post(); ?>       
                              <div class="box">
                                <h4><?php the_title() ?></h4>
                                <?php the_content() ?>

                 <?php endwhile; wp_reset_query(); ?> 

           </div> <!-- / containerBoxes-->
share|improve this answer

Yes, it is possible. You'll want to look at the Order & Orderby Parameters to WP_Query and since you didn't give too many details here, you should probably also look at When should you use WP_Query vs query_posts() vs get_posts()? as well.

share|improve this answer

You can always add orderby to your URLs to specify a field to order the posts. Earlier today I gave an answer on how to do this with "nice" URLs.

So you ("only") need to generate the links on each archive page. This should be rather easy, but I think you can find plugins for that too.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.