Create redirection to random post

I hope everyone is safe.

Ok, so I need a little advice. Basically, I have a blog in which I would like a button that will lead to random posts of my WP website. But I also would like to give the choice to my visitors to filter for what type of posts (by the category type) they would get random posts.

For example:

Let’s say that my blog have 5 categories of posts: dog, cat, bird, fish, wolf.

We will have the “Random” button, and next to it, a choice by checkbox for each of these 5 categories. If the user check the box for “dog” and “cat” only, after clicking the “Random” button, a random post only from the “dog” or “cat” category will be loaded. Not “bird”, “fish” or “wolf”.

Currently, I temporarily set 5 random buttons, one for each category. If I click on the one associated with the “dog” category for example, a random post from the “dog” category will appear. So of course, I would like to replace that system with one button only, and the 5 checkbox. Preferably, I would like the script to FIRST randomly choose one of the category for which the checkbox have been checked. And SECONDLY, to randomly choose a post for this category.

Here is the code I have for the 5 buttons. Can you help me modify it to replace it with the checkbox system and one “random” button?

(NOTE: I am using the plugin “Redirect URL to Post” to generate the url redirecting to a random post)

[su_button url="https://website.com/?redirect_to=random&cat=2" style="flat" background="#2D9600" size="20" center="no" rel="nofollow"]DOG [/su_button]
<br>

[su_button url="https://website.com/?redirect_to=random&cat=5" style="flat" background="#2D9600" size="20" center="no" rel="nofollow"]CAT [/su_button]
<br />

[su_button url="https://website.com/?redirect_to=random&cat=6" style="flat" background="#2D9600" size="20" center="no" rel="nofollow"]FISH[/su_button]
<br />

[su_button url="https://website.com/?redirect_to=random&cat=7" style="flat" background="#2D9600" size="20" center="no" rel="nofollow"]BIRD [/su_button]
<br />

[su_button url="https://website.com/?redirect_to=random&cat=8" style="flat" background="#2D9600" size="20" center="no" rel="nofollow"]WOLF [/su_button]
<br />

I hope my explanation was clear.

Take care.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.