• Well today I have been reading and reading on this forum and trying to get it to work, but I can’t get my posts on the category pages I created to list alphabetical.

    Can someone help me?

    I created a category.php to list the article titles instead of the whole article on a certain category page. I just want all the posts on these pages to list alphabetical. The posts on the frontpage should stay listed by post date.

    Here is one of my category pages:

    https://www.mijnamsterdam.com/category/eten-drinken/

    and here is the main page:

    https://www.mijnamsterdam.com/index.php

    Thanks in advance!

Viewing 9 replies - 1 through 9 (of 9 total)
  • “Can someone help me?”

    Yep. In category.php, just above The Loop, add this bit of code, which makes use of query_posts:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("paged=$paged&cat=$cat&orderby=title&order=ASC");
    ?>

    Explanation of code and query_posts parameters:

    paged=$paged
    The first line assigns $paged the ‘paged’ query value so query_posts will correctly paginate (next/previous posts). If the paged query doesn’t exist, $paged gets the value 1 (first page).

    cat=$cat
    The cat parameter equals category ID; the $cat variable is a global value on category pages.

    orderby=title
    Should be obvious.

    order=ASC
    Sort from A-Z. Setting to DESC (the default) would reverse this.

    EDIT: If you’re using a “posts per page” plugin that let’s you set # of posts to display for each page under categories, archives, etc., add this to your parameter string:

    &posts_per_page=$posts_per_page

    $posts_per_page is also a global variable.

    Thread Starter utopiad

    (@utopiad)

    You rock!!

    Thanks a lot!

    This is very close to what I want, but I want all Titles of posts to appear in their given category page.

    Using query_post variables, I’ve attempted to force the cat page to list all posts titles alphabetically on one page. The thing is, the above code, nor my own attempts (deleting the paged=$paged parts & adding what I figure to be the necessary parameters) do anything to change how the posts are listed.

    The only reason I can think that this is the case is because my category pages are viewed by cat-name-slug, not ID. I need a global cat variable, because I want this to work for more than one category using the same file. I have been unable to discover the needed parameter.

    Would anyone be willing to clue me in?

    I admit this stuff gets a little over my head, but taking my cue from Kaf’s code above, I wrote:

    <?php
    $cat = (get_query_var('category_nicename')) ?
    get_query_var('category_nicename') : 1;
    query_posts("posts_per_page=-1&cat=$cat&orderby=title&order=ASC");
    ?>

    I placed this just above the <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?> line. And still absolutely NOTHING changes.

    The posts still lists under the appropriate category page according to the dates they were posted in descending order.

    I know I am editing the right page (in case anyone was wondering), because when I messed up the code just right at one point I got a page error.

    What am I doing wrong?

    I’ve continued my research and have reduced the code to:

    <?php

    $category_name = query_posts($query_string . '&orderby=title&order=asc&posts_per_page=-1');
    ?>

    But, still, no change.

    Anyone getting tired of me, yet? ??

    I found the code that gives me what I’ve been looking for in a support post by asianmack – in case anyone wants to know.

    Gee, I hope my monologue helps someone . . .

    Thread Starter utopiad

    (@utopiad)

    Haha I don’t know what I did and how I did it, but I managed to get my category pages to list the posts alphabetical except for 1 entry…

    https://www.mijnamsterdam.com/category/eten-drinken/

    Look the first starts with a C and the second post with an A ascending to Z… weird he?

    Only adjestment I made was adding a plugin which allows me to set the max number of posts on category pages to 999, this was 10 normally, but now 11 posts are sorted alphabetical but 1 isn’t?!?!

    Can someone help me out here…

    Thread Starter utopiad

    (@utopiad)

    Is it possible to add sub titles like: “May 2005”, “April 2005” etc on a category page?

    I want to use it at the category pages of https://www.gumball-3000.com/rally/

    Thread Starter utopiad

    (@utopiad)

    Anyone?

    Is there a way to transform category pages to archive layout?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Listing posts on category page alphabetical’ is closed to new replies.