random posts plugin. Version: 1.0 Author: The Barry Bittwister Cabal Author URI: http://singlenesia.com */ class drt_randposts { function get($limit = 10, $show_pass_post = false) { global $wpdb, $tableposts; $sql = "SELECT distinct ID, post_title, post_content, post_date, post_author FROM $tableposts WHERE post_status = 'publish' "; if(!$show_pass_post) $sql .= "AND post_password ='' "; $sql .= "ORDER BY RAND() LIMIT $limit"; $posts = $wpdb->get_results($sql); return( $posts ); } function show ($limit = 10, $len = 20, $show_dateline = false, $show_excerpt = false, $show_pass_post = false ) { $posts = drt_randposts::get( $limit, $show_pass_post ); $output = ''; foreach ($posts as $post) { $permalink = get_permalink($post->ID); $post_title = stripslashes($post->post_title); $post_title = str_replace('"', '', $post_title); $post_title = '' . $post_title . ''; $post_content = strip_tags($post->post_content); $post_content = stripslashes($post_content); $words=split(" ",$post_content); $post_strip = join(" ",array_slice($words,0,$len)); if( class_exists( "drt_disco" ) ) { $d = drt_disco::mysql2disco( $post->post_date ); $strs = $d->Disco(); $post_date = $strs['season']."/".$strs['day']."/".$strs['year']; $post_date_gf = date( "F d,Y", $d->Unix() ); $dateline = ''.$post_date.':'; } else { $i = mktime( substr( $post->post_date,11,2 ), substr( $post->post_date,14,2 ), substr( $post->post_date,17,2 ), substr( $post->post_date,5,2 ), substr( $post->post_date,8,2 ), substr( $post->post_date,0,4 ) ); $post_date_gf = date( "F d,Y", $i ); $dateline = ''.$post_date_gf.':'; } $output.="
  • "; if( $show_dateline ) { $output .= $dateline; $output .= ""; } else { $output .= $post_title; if( $show_excerpt ) $output .= ""; } $output.="
  • "; } echo $output; } } ?>