WordPress.org

Ready to get started?Download WordPress

Forums

Why won't my posts sort by post_name (slug)? (4 posts)

  1. buskerdog
    Member
    Posted 8 years ago #

    Here's my code:
    <?php get_posts('orderby=post_name&order=DESC'); ?>
    <ul class="menubox"><?php while (have_posts('')) : the_post(''); ?>

    <li><a href="<?php the_permalink() ?>"><?php the_excerpt(); ?><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>

    and here's my URL: http://tinyurl.com/lof3u (please don't post the actual URL, I don't want the thread to cache on google)

    What am I doing wrong? I made the post slugs just the last names so that I could sort the page alphabetically... and I can't figure out how to make it happen.

  2. buskerdog
    Member
    Posted 8 years ago #

    no one knows this?

  3. Michael Bishop

    Posted 8 years ago #

    I don't think you can pass those parameters to get_post

    Take a look at this
    Template_Tags/query_posts#Example_1

  4. virgvv
    Member
    Posted 7 years ago #

    I'm having the same problem. I've got a category archive of author names, and want to sort on the slug (last name). I'm using query_posts rather than get_posts, like so:
    query_posts('cat=54&orderby=post_name&order=asc')

    Is it really impossible to sort posts by slug?

    Or am I just missing something?

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic