query('showposts=1&orderby=rand&cat=-'.exclude_comic_categories()); 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['randompost'] ) ) add_action( 'template_redirect', 'random_post' ); class widget_comicpress_random_post extends WP_Widget { function widget_comicpress_random_post() { $widget_ops = array('classname' => 'widget_comicpress_random_post', 'description' => __('Displays a link to click to trigger a random blog post.','comicpress') ); $this->WP_Widget('random_post', __('Random Post','comicpress'), $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; }; ?>