Advertisement
andraantariksa

Membuat Random Post di Wordpress

Jan 14th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.28 KB | None | 0 0
  1. <?php
  2. $post_amount = 5;
  3. $random_posts = get_posts('numberposts='.$post_amount.'&orderby=rand');
  4. foreach( $random_posts as $post ){
  5. setup_postdata($post);
  6. ?>
  7. <div>
  8. <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  9. <div><?php the_excerpt(); ?></div>
  10. </div>
  11. <?php
  12. }
  13. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement