WordPress.org

Ready to get started?Download WordPress

Forums

alphabetical posts (31 posts)

  1. jdbg
    Member
    Posted 9 years ago #

    Hi,

    I've looked around the forum, as well as in the documentation, but didn't find it, so I'm asking here.

    How can I make my posts to be sorted alphabetically on my index - i.e. I want my posts to sort not by date, but by the name of the title of the post.

    Thanks in advance.

  2. asianmack
    Member
    Posted 9 years ago #

    I am also trying to do the same thing: Sort posts alphabetically in a Category. This is easy to do in Movable Type, but I'm eager to replatform my site to WordPress and am in need of this functionality. Anyone out there with suggestions?

  3. lostinymysphereagain
    Member
    Posted 9 years ago #

    &sort=post_title&order=ASC')

    add that in to something for example:

    <?php wp_get_archives('type=postbypost&sort=post_title&order=ASC'); ?>

  4. asianmack
    Member
    Posted 9 years ago #

    lostinmysphereagain, thanks for the reply. That works in listing the titles of each post (as links), but it doesn't actually display the full content of the post. Here is what I'm trying to do (as displayed through MT): http://www.asianmack.com/archives/cat_alternative.html

    Here is the same version I'm trying to convert over to WordPress:
    http://www.asianmack.com/wordpress/index.php?cat=2

    As you can see, each post assigned in the particular Category in the MT version is displayed in alphabetical order by post title. I'm not versed in PHP, so I may be missing something obvious. Again, any tips would be appreciated.

  5. lostinymysphereagain
    Member
    Posted 9 years ago #

    ah i see. I don't know in that case. sorry.

  6. asianmack
    Member
    Posted 9 years ago #

    Thanks for your help regardless! Anyone else out there with any suggestions?

  7. asianmack
    Member
    Posted 9 years ago #

    Ok, so for anyone that's been folowing this post or is interested in sorting posts in alphabetical order rather than by date authored, I have made some headway.

    Here's my Category view sorted by default (Date authored):
    http://www.asianmack.com/wordpress/index.php?cat=2

    Here's my Category view sorted the way I want it (Alphabetically):
    http://www.asianmack.com/wordpress/index.php?cat=2&orderby=title&order=asc

    Now the problem is, how do I get the links generated in wp_list_cats() to append that query string? Anyone out there have any ideas?

  8. asianmack
    Member
    Posted 9 years ago #

    I finally figured this out. Anyone who wants to change the sort order of posts within a category listing should put the following code before The Loop.

    <?php if (is_category()) { $posts = query_posts($query_string . '&orderby=title&order=asc'); } ?>

  9. kayaker
    Member
    Posted 9 years ago #

    Thanks! That works great!

  10. espek
    Member
    Posted 9 years ago #

    Wonderful! That does the trick in a very elegant fashion. Good work!

  11. kirkir
    Member
    Posted 9 years ago #

    Could be that I'm having a dense moment but I am having the same issue and I can't seem to be able to resolve it.

    I need to be able to list all the posts on my wordpress blog in alphabetical order (regardless of the categories each post is in). Meaning, I need to devise a page or some place where visitors to my site can see a list of all the posts in the blog alphabetically, like an index.

    Anyone with any helpful ideas on how to accomplish this? I am still a bit new to the php coding aspect of things so please be gentle with that. Thanks in advance!

  12. Bard09
    Member
    Posted 9 years ago #

    I just would like to thank you Asianmack for the great bit of code. Was banging my head into the wall over this.

  13. sarahknz
    Member
    Posted 9 years ago #

    Thanks, that's brilliant. I sent my self 500+ emails tracking the code through apply_filters(). I expected to find there was something in wp-settings or similar.

    My version didn't like just appending the string so I did a string replace. Phew. So happy to have it fixed.

    thanks, thanks, thanks!

  14. awsamuel
    Member
    Posted 9 years ago #

    I'm just trying to create an alphabetical index of post titles, but for some reason when I get my list of posts they are in chronological rather than alphabetical order even though the lis was generated by this code:
    <?php
    wp_get_archives('type=postbypost&sort=post_title&order=ASC');
    ?>

    Any thoughts?

  15. skippy
    Member
    Posted 9 years ago #

    I have distilled the bulk of this thread into a Codex contribution: Alphabetizing Posts.

  16. 2shoes
    Member
    Posted 9 years ago #

    How would you do this in the Smarty Templating engine?

  17. Dgold
    Member
    Posted 8 years ago #

    I think there's an error in the Codex, shouldn't there be a closing
    ?>
    in the example for Alphabatizing posts under the heading "Category Template"?

    I found I needed to put that.

  18. snoogly
    Member
    Posted 8 years ago #

    When I use this to order search results I get broken next and previous buttons. They don't do anything, and I can only see the first page of posts.

  19. jwurster
    Member
    Posted 8 years ago #

    I've been using the custom query string plugin http://mattread.com/archives/2005/03/custom-query-string-plugin/ for a week and it seems to do this.

  20. snoogly
    Member
    Posted 8 years ago #

    works well, but still doesn't solve the problem of broken navigation on tag search results pages listed alphabetically

  21. Nicki Faulk
    Member
    Posted 8 years ago #

    jwurster, if I could reach you I would HUG YOU!!!!

    I've been pulling my hair out all afternoon when I finally had enough entries in my categories to see/realize that the category pages weren't paginating correctly, and removing the alphabetizing code solved the problem (but didn't look the way I wanted).

    That plug was exactly what I needed, and lets me keep my hair intact. ;)

    Thank you, thank you, thank you, thank you, THANK YOU! :D

  22. Dgold
    Member
    Posted 8 years ago #

    This is exactly what I need to do... Just what this thread talks about, BUT on a PAGE not on a Category or Index. When I try this on a Page (Archives Template), the result is a list of pages not a list of posts. Anyone know what to do?

    kirkir wrote:

    I need to be able to list all the posts on my wordpress blog in alphabetical order (regardless of the categories each post is in). Meaning, I need to devise a page or some place where visitors to my site can see a list of all the posts in the blog alphabetically, like an index.

    Anyone with any helpful ideas on how to accomplish this?

  23. richarduk
    Member
    Posted 8 years ago #

    How about this ?

    Create a default category called Alphabetical.

    Every post will end up in this category, even if you're half-asleep :-)

    Link to this Alphabetical category, where you can order the posts alphabetically as described above.

  24. jennavery42
    Member
    Posted 8 years ago #

    I want to alphabetize ALL my posts. I want to retain category information, so I don't want to use only a specific category solution.

    When I add this code (from http://codex.wordpress.org/Alphabetizing_Posts):

    <?php
    // we add this, to show *all* posts sorted
    // alphabetically by title
    $posts = query_posts($query_string . '&orderby=title&order=asc&posts_per_page=-1');
    // here comes The Loop!
    if (have_posts()) : while (have_posts()) : the_post(); ?>

    to my index.php file for my theme, I get a blank page.

    Suggestions?

  25. jennavery42
    Member
    Posted 8 years ago #

    p.s. - by blank page, I mean that my entire blog disappears.

  26. jennavery42
    Member
    Posted 8 years ago #

    If someone would please help with this I would really appreciate it.

  27. syncbox
    Member
    Posted 8 years ago #

    Per the code in the excellent plugin by Mike Smullin

    http://www.mikesmullin.com/2006/05/23/wordpress-plugin-sort-category-posts-by-title/

    you can place this before your query and it will sort by post title

    <?php add_action('pre_get_posts','sort_categories_by_title');

    function sort_categories_by_title($x) {
    if(is_category()) {
    $x->query_vars['orderby'] = 'title';
    $x->query_vars['order'] = 'ASC';
    }
    }
    ?>

    If you install the plugin, all your category displayed posts will be alphabetical... by putting it just in the category templates where you want that sorting... you can keep the other categories date based.

    Seems to work for me.

  28. buskerdog
    Member
    Posted 7 years ago #

    Does this not work with sortby=post_name? I'm listing artists and have full names for post titles but last names for slugs since I was hoping to use post_name to sort (i.e. sort by last name but display full names with the title) but it's not working.

  29. bmasterflash
    Member
    Posted 7 years ago #

    I have my posts Alphabetized, but I was wondering if there is a way to have the first word ignored if it is "the" So a post tittled "The Car" would be in the C's. Any suggestions would be great. Thank you.

  30. bmasterflash
    Member
    Posted 7 years ago #

    anyone?

Topic Closed

This topic has been closed to new replies.

About this Topic