Support » Fixing WordPress » Alphabetizing posts in a category

  • I am not a coder by any stretch of the imagination, and have been wrestling with alphabetizing posts within a category on a page. The page in question is

    Each vendor is a post given a category of vendor, and I want them to sort in alpha order on the page.

    I have tried quite a few things, including

    if (is_category('Vendors'))
         $posts = query_posts($query_string .

    [Please post code or markup snippets between backticks or use the code button.]

    and have had no luck. I know absolutely nothing about php, so it’s driving me bug effing nuts. I’ve gone through posts, worked with the template creator (who also didn’t solve it), etc. Who would think it would be this HARD to sort posts in anything but date order?

    I would hugely appreciate any help whatsoever. The client is screaming and I’m ripping my hair out.

Viewing 6 replies - 1 through 6 (of 6 total)
  • esmi


    Forum Moderator

    Have you looked at category templates?

    I did, but here’s another question.

    Where do you find where the category number/id is? I couldn’t find anything at all under the manage/categories. Heck, there’s not even anything called “Manage.” When I clicked on the categories, there is no number anywhere. One of my many frustrations today; all of these hints, tips, etc. seem to be written by geekies for geekies. Us normal people are just left blundering around trying to figure things out.



    Forum Moderator

    Where do you find where the category number/id is?

    Best answered by How do I find an id?.

    That helps Esmi. Am still confused; it has nothing about alphabetizing a page? And do I add the alpha to some kind of page.php versus a category php since these posts are being displayed on a page called vendors? I don’t have a page php file; I do have an archive php file.

    I may need to sleep on this tonight, after wrestling with it for over four hours my brain is total mush. I hate feeling stupid; I am NOT stupid. This just is not at all straightforward.



    Forum Moderator

    it has nothing about alphabetizing a page?

    Agreed but by taking the template route, you sidestep the need to use conditionals to test which category you are in before you decide whether or not to use a custom query. All of your custom code can be safely kept in a category-specific template whilst your other categories remain untouched. Sometimes, using this kind of template/modular approach simplifies the coding.

    these posts are being displayed on a page called vendors?

    Now is this a static Page of posts? Or a category listing? The two are very different so it’s important that you decide which you are using.

    I do have an archive php file

    If this is a category listing, you can create a category specific template by simply making a copy of archive.php and renaming it category-vendors.php. That will set the template up for you to begin working with.

    Back to working on this alphabetizing problem.

    I have created a page, called vendors, post ID 12.

    Likewise I have created a category, called Vendors.

    I then have created a number of posts, each having a separate post ID. I have marked them to go in the category called “vendors.”

    Those posts then automatically post on the “Vendors” page. It all works beautifully except that they display on the vendor page in date order, not alpha order. And I can’t seem to find the right code to put in the right place to have those posts sort in alpha order on the Vendors page of the site.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Alphabetizing posts in a category’ is closed to new replies.