Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 112716

Norris Stevens on "Orderby code not working"

$
0
0

I want to allow users to order a posts list through a drop-down menu, but I can't get the following code to work.

<div class="sort">
     <select onclick="if (this.value) { document.location = this.value; }">
        <option value="" selected="selected">Sort by</option>
        <option value="<?php echo $short_page_url; ?>?orderby=title&order=ASC">Titles Z-A</option>
        <option value="<?php echo $short_page_url; ?>?orderby=title&order=DESC">Titles A-Z</option>
     </select>
</div>

<?php $posts = get_posts("numberposts=20&cat=30"); foreach ($posts as $post) : setup_postdata($post); ?>

CONTENT GOES HERE

<?php endforeach; ?>

Any help would be appreciated.


Viewing all articles
Browse latest Browse all 112716

Trending Articles