• I’ve looked online for around 5 hours for a plugin or solution to reorder posts in a random order when a category of posts are displayed.

    I’ve found many posts that reorder lists. These are great for the menu and work well. However, I’d like to reorder posts everytime a user selects a category.

    I’m guessing that there is a wordpress brain lurking in this forum that may have an answer or solution

    If anyone could help I would greatly appreciate it. Thanks. 🙂

Viewing 13 replies - 1 through 13 (of 13 total)
  • And the search doesn’t work?
    I found this in two minutes (with reading) by searching “random post order”
    http://wordpress.org/support/topic/91421?replies=8

    Thread Starter skript03

    (@skript03)

    Amazing. I looked for a VERY long time and read ever damn bit of it:)

    Thanks for helping, and making me look slow.

    I’ll give it a shot. Hopefully it’ll work first time around.

    Thread Starter skript03

    (@skript03)

    I’ve attempted adding the loop to the archive.php in my theme that I am using. I’m 100% sure i’m doing it incorrectly.

    I’ve tried adding the loop to the archive.php document and replacing the loop in the archive.php document. Neither worked. to save time the code to paste from the link you mentioned is listed below. Am I adding it to the wrong php. file?

    Essentially I’d like a category to be picked, and the posts displayed to be randomly organized.

    Thanks again:) You guys are pure genius.

    <?php global $wpdb; $numposts = 1; $rand_posts = $wpdb->get_results(“SELECT * FROM $wpdb->post2cat,$wpdb->posts,$wpdb->categories WHERE $wpdb->post2cat.post_id = $wpdb->posts.ID and $wpdb->post2cat.category_id = $wpdb->categories.cat_ID and $wpdb->posts.post_status = ‘publish’ and $wpdb->categories.cat_name = ‘featured’ ORDER BY RAND() LIMIT $numposts”);
    foreach($rand_posts as $post) :
    setup_postdata($post);
    ?>

    I have no idea, I am not a coder… just a “traffic director” 🙂

    Anyway, I’d create Category Template(s) to make sure the code doesn’t interfere with other “archives” (e.g. monthly).

    Also, the code might be not compatible with the latest WP versions.
    For example post_status = 'publish' is not enough for sure – you need to add post_type = 'post' since 2.1.

    Another option might be to take a look at the query_posts tag:
    http://codex.wordpress.org/Template_Tags/query_posts
    It can modify your Loop in the Cat templates.

    Thread Starter skript03

    (@skript03)

    I appreciate your ‘traffic directing’.

    You led me in the right direction.

    Maybe someone will see this thread this evening and have a brilliant idea. It seems like it would be a common request, but there’s not much documentation on it.

    Thanks again.

    Thread Starter skript03

    (@skript03)

    I’ve made some progress. This works in ordering posts before the loop occurs.

    <?php query_posts($query_string . “&order=ASC”); ?>

    this is placed before the loop. It of course, puts the items in ascending order.

    What would I type in “&order=_____” to cause them to display in a random order?

    I appreciate the support greatly.

    You posted a code snippet above… did you take a closer look at it?
    (hint: RAND)

    Thread Starter skript03

    (@skript03)

    I gave RAND a shot. Nothing happened. I also tried lower case rand. random, RANDOM… I made sure to go through the trial and error process prior to asking the question. I’m not a big fan of people who won’t attempt to solve the problem before they ask. I’m sure you feel the same way.

    I’m putting in the effort… Apparently I lack on php. smarts.

    After decoding your riddle:) I’ve come to the conclusion that: ORDER BY RAND() LIMIT $numposts”) may work.

    I’m taking a stab at it.. Correct me if I’m wrong please. Thanks again.

    Thread Starter skript03

    (@skript03)

    I’ve given the RAND() option several shots using
    <?php query_posts($query_string . “&order=RAND()”); ?>
    before the loop. It doesn’t seem to have any effect. Does anyone else have any thoughts?

    Thread Starter skript03

    (@skript03)

    Have I been posting this in the right area of the support forum or should I post it elsewhere? Just let me know.

    Thanks:)

    Thread Starter skript03

    (@skript03)

    Just wondering if there is anyone around right now to help with this problem. I can’t really move on with my project until I solve it:)

    As Always, Thanks for the help.

    instead of order=rand try orderby=random

    In your archive.php or category.php :

    <?php $posts = query_posts($query_string . ‘&orderby=rand&posts_per_page=20’); ?>

    <?php while (have_posts()) : the_post(); ?>

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘help with Random Display of Posts’ is closed to new replies.