post-page

Nicer archives with sorting by category for WordPress

17
responses
by
 
on
February 17th, 2004
in
WordPress Hack

I had modified Codegurl’s nicer archives to work with 1.0+ but had forgotten about the mutiple categories stuff. I tried to work around it today to no avail and it was bothering me enough that I finally gave up and redid the archives to work with mutiple categories.
You can see it at work at http://weblogtoolscollection.com/wordpress/narchives.php

Since posts have multiple categories, they show up under multiple times in archives. In other words, a post listed under “general” and under “code” will show up twice in these archives. There is a sort option for ascending and descending, sort by author, date, title, category (of course). I also took the libery of integerating it into the WP framework of pages so it follows the same CSS file and shows the menu.

Please post bugs on here.

Peace

Download the source here: http://dinki.mine.nu/weblog/b2-img/narchives.phps

heading
heading
17
Responses

 

Comments

  1. Ruby Sinreich (3 comments.) says:

    I tried an earlier version of this and couldn’t get it to work. This time it took right away! Thanks so much!!!! I was dreaming of something like this in MT, leave it to WP (and you) to make it effortless…

  2. Henriette (5 comments.) says:

    … ended up using podz’ narchives2.php, here:
    http://wordpress.org/support/topic.php?id=15653

    Thanks!

  3. Henriette (5 comments.) says:

    Category is broken:
    – a “group by” would help, as they aren’t sorted in any way, and double entries abound. I think best might be a “group by date” or a “group by post title”.
    – also, if I select both category and current year I get all posts for that year, including ones not yet published. Dunno how to fix that; it’s rather noticeable right now, with only a few posts for the year.

    There are other things: the defaultorder and defaultorderby are still broken, even given the fix given above. Removing the “default” bits from those helps, but selecting, say, category, after showing the default “date” and “ASC” reverts the selection to descending.

    Also, not everybody has multiple authors. As is, the script shows all registered users – I think it should only list those who have posted something.
    It’s easy enough to comment out the author_select function and its calls, but it might be made into an option.

    (I’d really like a select by date, order by category and year … alas, my php skills arent’ up to it.)

    Very nice idea, but I’d really like to know enough php to give the script a thorough overhaul.

  4. Jonathan says:

    Hi there,
    I am trying to find way to change the defaults on this. I’d like Catagory and ASC to be the default sort options.
    I’ve seen plenty of messages all over the place that talk about how to change these defauts but I’ve found nothing that actually conclussively describes how to do it in a way that works.

    Can you tell me how? Would certainly appreciate it.

    Thanks

  5. Lorelle VanFossen (7 comments.) says:

    It seems the overwhelming request is to change the default sort order to category, but there is no concensus on how to do this. It would be very helpful to have the explanation here, if not in the file itself in a comment.

    This is a brilliant addition to WordPress.

  6. phpNeophyte (2 comments.) says:

    I’ve incorporated your Nicer archives with sorting, I tried to change the default listing by categories by changing
    $defaultorderby = ‘category';
    $defaultorder = ‘DESC';

    That didn’t do it so I diddled here and there trying to see if I could make the initial view sorted by Category rather than Date. Can you help me accomplish this at http://organicgardensite.com/narchives.php? Thanks

    Kevin

  7. Mark (36 comments.) says:

    Find this line:
    function show_orderby_select() {
    global $orderby;

    and add this right below it:
    if ($defaultorderby) $orderby = $defaultorderby;

  8. phpNeophyte (2 comments.) says:

    :???:mmmm that didn’t do it. I made sure I had your script from the link in this article, re-did the page, made that change you suggested above and… still defaults to monthly view first. Is there a “select” that needs to be changed?

    Kevin

  9. Mark (36 comments.) says:

    Ok, I see your point. It is broken at my end as well. I am going to be gone for a couple of days and I will look at it when I get back. Sorry for the delay. :sad:

  10. Eduardo says:

    Hey LL,
    I am trying to run the hack, but i get a parse error on line 42 (both locally and online at my host’s server). Would you give me a hand? I started a thread in WP’s forum, http://wordpress.org/support/10/4150 .
    Thanks a lot,
    Eduardo (anatman in the forum)

  11. Mark (36 comments.) says:

    @anatman:
    I cannot reproduce the error on any server/machine. I have looked through the code, compared the code between your .phps and mine and everything is exactly the same. I have to say something is happening on your side which is causing this error. Can you give us any other information? Anything else that might be peculiar about your systems?

    I have one more thought. Your text editor could be replacing the newline character to be a new line instead. Try replacing the \n with a <br/>

  12. Alex (3 comments.) says:

    I keep getting the following error:
    Fatal error: Call to undefined function: wp_list_cats() in /Library/WebServer/Documents/archives.php on line 228
    Everything else works like a dream though. I have tried everything and can’t ge this to work.

  13. Alex (3 comments.) says:

    Never mind, fixed it ;)

    I am looking for a way to limit initial display to 3 months, but for some reason $what_to_show is completely ignored.

  14. Carthik (25 comments.) says:

    The link to the example on this blog is broken, compress should be com…just so you know. :)

  15. rk says:

    The link is still broken.
    In the Archiv, when I sort “All Years” not shown all month of the first year… :?::!:

  16. Jonathan (2 comments.) says:

    I’m still hoping to get some definitive info on how to get this to display Category as the default. Thanks a lot…



Trackbacks/Pingbacks

  1. […] simple addition that will add an archives page to your blogs. This function is based on Mark&#82 […]

Obviously Powered by WordPress. © 2003-2013

page counter
css.php