query('showposts=1&orderby=rand&cat='.get_all_comic_categories_as_cat_string()); while ($randomComicQuery->have_posts()) : $randomComicQuery->the_post(); $random_comic_id = get_the_ID(); endwhile; wp_redirect( get_permalink( $random_comic_id ) ); exit; } if ( isset( $_GET['randomcomic'] ) ) add_action( 'template_redirect', 'random_comic' ); class widget_comicpress_random_comic extends WP_Widget { function widget_comicpress_random_comic() { $widget_ops = array('classname' => 'widget_comicpress_random_comic', 'description' => 'Displays a link to click to trigger a random comic.' ); $this->WP_Widget('random_comic', 'Random Comic', $widget_ops); } function widget($args, $instance) { global $post; extract($args, EXTR_SKIP); echo $before_widget; $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }; ?>