WordPress.org

Ready to get started?Download WordPress

Forums

Proplems with Displaying posts in certain orders (i'm stuck!) (14 posts)

  1. skript03
    Member
    Posted 7 years ago #

    I posted a request for a solution for this problem in the mod section and was unable to get a solution. I thought this may be a more appropriate area to post my question.

    I have been working pretty hard to display my posts in random order when a category of posts is selected from the menu. I've found plugins to modify the lists in the menu. and I've found resources to list the displayed posts by name,date,time,descending,ascending... and all other sorts of order. I can't find the correct way to make my posts display in a random order.

    All of the previous orders where accomplished by using:
    <?php query_posts($query_string . "&order=ASC"); ?>
    I put this in the archive.php file right before the loop. Worked like a charm. When I try to make it RANDOM rather than ASCENDING I fail.... Miserably.

    I've tried RAND, RAND(), RANDOM, random, rand()....ect.

    I'm sure I'm missing something, and I'm sure there is a very bright person here who can possibly help. It'd be much appreciated. I'm absolutely stuck.

    Thanks soooo much in advance.

  2. ccoupe
    Member
    Posted 7 years ago #

    Just a guess. Does the doc for query_posts describe the allowable arguments?

  3. skript03
    Member
    Posted 7 years ago #

    http://codex.wordpress.org/Template_Tags/query_posts

    The query_posts doc is what's gotten me this far. It say there are a bunch of options not listed. I'm assuming that some sort of RAND() feature is an option.

    I just can't figure out how to make it apply.

  4. ccoupe
    Member
    Posted 7 years ago #

    I think you answered your question with "assume". Without looking in the code to find the undocumented settings, I wouldn't hazard a guess what they are, or if they work, or would work in the future.

    You have posts from ID:#1 to ID:#"unknown but ever growing" in the data base. Which may be deleted or are pages and and not posts. Bonus points to learn they aren't date sequential in the DB. Even if you get a RAND out of php or mysql (and you can), that doesn't mean it points to anything you can display and the recursive crawl to find a displayable just makes my skin crawl.

    A small matter of coding that makes my skin crawl.

  5. skript03
    Member
    Posted 7 years ago #

    I came up with this on another site.

    Will this work??

    http://www.desilva.biz/mysql/random.html

    I'm not sure how to implement it, but it looks like it my be a step in the right direction.

    Thanks for the assistance

  6. ccoupe
    Member
    Posted 7 years ago #

    Seems like it might. All you have to do next is get that into a php script of your own.

    You really don't want to do that. Why are archives random? Except for your enjoyment, do you really want that? I wouldn't visit.

  7. skript03
    Member
    Posted 7 years ago #

    Any thoughts on how to implement this mysql info to make the posts appear in random order?

  8. skript03
    Member
    Posted 7 years ago #

    CCOUPE-

    it's not that I want the archive to be random. I'm using the archive section to ranomly display peoples artwork. I'd like everyone to have a equal shot at 1st, 2nd, 3rd ect. Using the archive allows me to organize the different artwork in the Posts.

    It makes the organization on the backend easier.

    Obviously making them appear in a random order is pretty hard. I don't think I've ever asked a questions that has been so difficult to locate an answer.

  9. ccoupe
    Member
    Posted 7 years ago #

    Ah, - Random images are much easier that random posts. I misunderstood the question.

    I did something similar once with random banner pictures using someone else's script. Sadly, the author has moved on to other projects so I can find his website and it's too long to post here. Contact me via my profile and website and I can email it to you. It's only a starting point for what you want though.

    You might find that a plugin already exists (reinvented many times). If there is commentary about the image, that makes it a bit harder, You might want to look at the photo galleries subsystems and WP integration tools.

  10. skript03
    Member
    Posted 7 years ago #

    Thanks for the help. The image shuffle would work fine also. As long as they can be used as links.

    I'll contact you via email for more info.

    Thanks again

  11. whooami
    Member
    Posted 7 years ago #

    speaking of shuffling..

    all you have to do is this:

    shuffle(query_posts("all your other crap in here"));

    leave out the rand thing, thats useless. I could have saved you alot of time If i'd read this earlier.

  12. skript03
    Member
    Posted 7 years ago #

    It worked..... So simple. I'm amazed at how easy that was. I think next time I have to do this it may be a little easier;)

    Thank you so much for the help.

  13. whooami
    Member
    Posted 7 years ago #

    youre welcome :)

  14. junelle
    Member
    Posted 6 years ago #

    Thanks Whooami ... i have been looking for this solution for a DAY now ... THANKS A LOT!

Topic Closed

This topic has been closed to new replies.

About this Topic