• Hi everyone,

    here’s the issue im running into:

    I have a bunch of categories and id like the user to have the option to sort the posts by date added and alphabetical order with hyperlinks.

    example: Sort by Date Added | Alphabetically

    The code ive used so far is as follows:

    <?php if($_GET['sort'] == 'title') query_posts('orderby=title&order=ASC'); ?>
    
    <?php if (have_posts()) : ?>
    
    <a href="<?php echo str_replace(('?'.$_SERVER['QUERY_STRING']), '', $_SERVER['REQUEST_URI']).'/?sort=title'; ?>" class="alpha">Sort by Alphabetical Order</a>
    <a href="<?php echo str_replace(('?'.$_SERVER['QUERY_STRING']), '', $_SERVER['REQUEST_URI']); ?>" class="date">Sort by Date Added</a>
    
    <?php endif; ?>

    The issue is when ordering the posts alphabetically, all the posts within the blog show up. Id like it to be constrained to the category it is in.

    I have not setup any additional page templates as it would get quite tedious.

    Id like to know how you could pass a query so that wordpress could recognize the category it is in and sort posts from there onwards.

    Any help is much appreciated ??

    thanks!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Sort Posts within catergory with link’ is closed to new replies.