Support » Fixing WordPress » random post upon link

  • hi.. i see Alex’s plugin for random posts.. it looks really good.
    how can i use this such that you get random posts upon hitting a link?
    so the index page would reload (or load, if link had been clicked from an archive page) and have random posts in place of the originally-shown posts..
    thanks in advance…

Viewing 2 replies - 1 through 2 (of 2 total)
  • Mark Jaquith


    WordPress Lead Dev

    You could create a variable, maybe called “random_posts.”
    Create a link to
    In your index.php file, you can check to see if random_posts is set like so:
    <?php if ($_GET['random_posts']) {
    } ?>

    obviously, you’d want to integrate this into the “if ($posts)” conditional, so that only the random posts would be shown.
    That should give you the general idea of how to do it.

    thank you for that, mark..
    i played around with your suggestion for a while.. it looks completely correct and useful–if only i knew the proper syntax to make the rest of the wordpress php code mix in with it. but i guess i’ll learn/figure that out eventually…
    i’ve realized:

    • i’m really going to have to learn php sooner than later to do what i’d like to do with wordpress
    • while Alex’s plugin is great, i’m looking for something that can reproduce the entire post–author and all… so probably something that can return an entire container/div-enclosed section/include of all the pieces that make up the view of “one post” (author, permalink, date, title, content, comment-link, etc.)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘random post upon link’ is closed to new replies.