Support » Plugins and Hacks » Allow user to sort post

Allow user to sort post

  • DarioDN


    Hi guy… by query_posts I’ve listed my posts.
    So, I would allow user to change order the list by parameters like “author” or “custom field”.
    Now, I’m writing this code:

    <?php $sort= $_GET['order'];
    if($sort == "A")
    $order= "orderby=title";
    if($sort == "B")
    $order= "orderby=author";
    <?php get_header(); ?>
    	<div id="content" class="narrowcolumn" role="main">
    <h2><?php the_title(); ?></h2>
    <a href="?sort=A">title</a>
    <a href="?sort=B">author</a>
    <?php query_posts($order.'&order=ASC');  ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <li>	<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></li>
    		<?php endwhile; endif; wp_reset_query();?>

    But it doesn’t works… How can I do!?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Allow user to sort post’ is closed to new replies.