I have my standard category page. On this page, I’d like to put a button which, when clicked, randomises the results shown on the category page.
I know I could make a rand-category.php page and send the user on to that page. Ideally though, I’d like a more elegant solution, possibly something that refreshes the results without moving the user on/away from the page.
You can actually change any of the query parameters (like the order) by adding them to the url.
For instance, the sample url below would randomize the posts on the category archive every time you refreshed, randomizing the results.
Below is a basic form with the orderby value that would refresh whatever page/template it shows on. (you would just need to add it to archive.php in your theme, or to the sidebar via an HTML widget)
You would just need to work out the ajax to refresh the HTML element holding your loop. (the guy over at this post is doing a ajax comment refresher, you could look at how he is reloading his loop via ajax
Simple solution I guess :
make a button/link with url to same page locationn
(ex for page “Our Page”: Random results )
modify the query args to randomise the results