use this template in a single page
<?php
/*
Template Name: Random3
*/
?>
<?php
$args = array(
'numberposts' => 1,
'orderby' => 'rand',
'post_type' => 'food'
);
// get a random post from the database
$my_random_post = get_posts ( $args );
// process the database request through a foreach loop
foreach ( $my_random_post as $post ) {
// redirect the user to the random post
wp_redirect ( get_permalink ( $post->ID ) );
exit;
}
?>
change args as you need
the link of the page will redirect the user to random post