Share Pastebin
Guest
Public paste!

Filip P259curar

By: a guest | Jun 19th, 2009 | Syntax: PHP | Size: 0.40 KB | Hits: 418 | Expires: Never
Copy text to clipboard
  1. <?php
  2. /**
  3.  * Template Name: Aleator
  4.  */
  5. $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";
  6. $test_id = $wpdb->get_var($query);
  7. query_posts('p='.$test_id);
  8. if (have_posts()) : while (have_posts()) : the_post();
  9. wp_redirect(get_permalink());
  10. endwhile; endif;
  11. ?>