create a link to a random post within the current category

I think it’s better to use get_posts function. You can change the number of posts that you want. I set the category id if you’re in a category page.

<?php
    rewind_posts() ;
    $args = array( 'numberposts' => 1, 'orderby' => 'rand') ;
    $exclude_posts = array() ;
    if ( have_posts() ) { 
        while ( have_posts() ) { the_post();
            $exclude_posts[] = get_the_ID() ;
        }
    }
    $args['exclude'] = $exclude_posts ;
    if( is_category() ) {
        $args['category'] = get_query_var('cat') ;
    }
    $rand_posts = get_posts( $args ) ;
    foreach( $rand_posts as $post ) {
        echo '<a href="' . get_permalink( $post->ID ) . '">Random Post</a>';
    }
    rewind_posts() ;
?>

I hope it helps you 🙂

UPDATE Now exclude the posts showed in this page