WordPress : Redirecting to a random page

December 5, 2010

To create a random redirect in WordPress, you need to query your posts and get a random post ID and then use wp_redirect() function in WordPress to redirect users away to that page.

 

Additionally if the redirect is a 301, you can add a status to the wp_redirect() function in the following way.

 

The default value if left empty is 302.

Tags: