Filip P259curar
By: a guest | Jun 19th, 2009 | Syntax:
PHP | Size: 0.40 KB | Hits: 418 | Expires: Never
<?php
/**
* Template Name: Aleator
*/
$query = "SELECT ID, object_id, term_taxonomy_id FROM $wpdb->posts as p, $wpdb->term_relationships AS t WHERE p.post_status = 'publish' && (p.ID = t.object_id) ORDER BY RAND() LIMIT 0,1";
$test_id = $wpdb->get_var($query);
query_posts('p='.$test_id);
if (have_posts()) : while (have_posts()) : the_post();
wp_redirect(get_permalink());
endwhile; endif;
?>